<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-2"></span><span>
</span><span id="line-3"></span><span class="hs-comment">{-|
Note [CSE for Stg]
~~~~~~~~~~~~~~~~~~

This module implements a simple common subexpression elimination pass for STG.
This is useful because there are expressions that we want to common up (because
they are operationally equivalent), but that we cannot common up in Core, because
their types differ.
This was originally reported as #9291.

There are two types of common code occurrences that we aim for, see
note [Case 1: CSEing allocated closures] and
note [Case 2: CSEing case binders] below.


Note [Case 1: CSEing allocated closures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The first kind of CSE opportunity we aim for is generated by this Haskell code:

    bar :: a -&gt; (Either Int a, Either Bool a)
    bar x = (Right x, Right x)

which produces this Core:

    bar :: forall a. a -&gt; (Either Int a, Either Bool a)
    bar @a x = (Right @Int @a x, Right @Bool @a x)

where the two components of the tuple are different terms, and cannot be
commoned up (easily). On the STG level we have

    bar [x] = let c1 = Right [x]
                  c2 = Right [x]
              in (c1,c2)

and now it is obvious that we can write

    bar [x] = let c1 = Right [x]
              in (c1,c1)

instead.


Note [Case 2: CSEing case binders]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The second kind of CSE opportunity we aim for is more interesting, and
came up in #9291 and #5344: The Haskell code

    foo :: Either Int a -&gt; Either Bool a
    foo (Right x) = Right x
    foo _         = Left False

produces this Core

    foo :: forall a. Either Int a -&gt; Either Bool a
    foo @a e = case e of b { Left n -&gt; &#8230;
                           , Right x -&gt; Right @Bool @a x }

where we cannot CSE `Right @Bool @a x` with the case binder `b` as they have
different types. But in STG we have

    foo [e] = case e of b { Left [n] -&gt; &#8230;
                          , Right [x] -&gt; Right [x] }

and nothing stops us from transforming that to

    foo [e] = case e of b { Left [n] -&gt; &#8230;
                          , Right [x] -&gt; b}


Note [StgCse after unarisation]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Consider two unboxed sum terms:

    (# 1 | #) :: (# Int | Int# #)
    (# 1 | #) :: (# Int | Int  #)

These two terms are not equal as they unarise to different unboxed
tuples. However if we run StgCse before Unarise, it'll think the two
terms (# 1 | #) are equal, and replace one of these with a binder to
the other. That's bad -- #15300.

Solution: do unarise first.

-}</span><span>
</span><span id="line-90"></span><span>
</span><span id="line-91"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Stg.CSE</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.CSE.html#stgCse"><span class="hs-identifier">stgCse</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-92"></span><span>
</span><span id="line-93"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-94"></span><span>
</span><span id="line-95"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-96"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-97"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html"><span class="hs-identifier">GHC.Stg.Syntax</span></a></span><span>
</span><span id="line-98"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-99"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Basic.html#isWeakLoopBreaker"><span class="hs-identifier">isWeakLoopBreaker</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-101"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#AltCon"><span class="hs-identifier">AltCon</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-103"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier">fromMaybe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-104"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Map.html"><span class="hs-identifier">GHC.Core.Map</span></a></span><span>
</span><span id="line-105"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html"><span class="hs-identifier">GHC.Types.Name.Env</span></a></span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#%3E%3D%3E"><span class="hs-operator">(&gt;=&gt;)</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-107"></span><span>
</span><span id="line-108"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-109"></span><span class="hs-comment">-- The Trie --</span><span>
</span><span id="line-110"></span><span class="hs-comment">--------------</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-comment">-- A lookup trie for data constructor applications, i.e.</span><span>
</span><span id="line-113"></span><span class="hs-comment">-- keys of type `(DataCon, [StgArg])`, following the patterns in GHC.Data.TrieMap.</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-keyword">data</span><span> </span><span id="StgArgMap"><span class="annot"><a href="GHC.Stg.CSE.html#StgArgMap"><span class="hs-identifier hs-var">StgArgMap</span></a></span></span><span> </span><span id="local-6989586621680955873"><span class="annot"><a href="#local-6989586621680955873"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="SAM"><span class="annot"><a href="GHC.Stg.CSE.html#SAM"><span class="hs-identifier hs-var">SAM</span></a></span></span><span>
</span><span id="line-116"></span><span>    </span><span class="hs-special">{</span><span> </span><span id="sam_var"><span class="annot"><span class="annottext">forall a. StgArgMap a -&gt; DVarEnv a
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var hs-var">sam_var</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#DVarEnv"><span class="hs-identifier hs-type">DVarEnv</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680955873"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-117"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="sam_lit"><span class="annot"><span class="annottext">forall a. StgArgMap a -&gt; LiteralMap a
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var hs-var">sam_lit</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Data.TrieMap.html#LiteralMap"><span class="hs-identifier hs-type">LiteralMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680955873"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-118"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.Data.TrieMap.html#TrieMap"><span class="hs-identifier hs-type">TrieMap</span></a></span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#StgArgMap"><span class="hs-identifier hs-type">StgArgMap</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-121"></span><span>    </span><span class="hs-keyword">type</span><span> </span><span id="Key"><span class="annot"><a href="GHC.Data.TrieMap.html#Key"><span class="hs-identifier hs-var">Key</span></a></span></span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#StgArgMap"><span class="hs-identifier hs-type">StgArgMap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span>
</span><span id="line-122"></span><span>    </span><span id="local-6989586621680955705"><span class="annot"><span class="annottext">emptyTM :: forall a. StgArgMap a
</span><a href="GHC.Data.TrieMap.html#emptyTM"><span class="hs-identifier hs-var hs-var hs-var hs-var">emptyTM</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SAM :: forall a. DVarEnv a -&gt; LiteralMap a -&gt; StgArgMap a
</span><a href="GHC.Stg.CSE.html#SAM"><span class="hs-identifier hs-type">SAM</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sam_var :: DVarEnv a
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var">sam_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DVarEnv a
forall (m :: * -&gt; *) a. TrieMap m =&gt; m a
</span><a href="GHC.Data.TrieMap.html#emptyTM"><span class="hs-identifier hs-var">emptyTM</span></a></span><span>
</span><span id="line-123"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sam_lit :: LiteralMap a
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var">sam_lit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LiteralMap a
forall (m :: * -&gt; *) a. TrieMap m =&gt; m a
</span><a href="GHC.Data.TrieMap.html#emptyTM"><span class="hs-identifier hs-var">emptyTM</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-124"></span><span>    </span><span id="local-6989586621680955701"><span class="annot"><span class="annottext">lookupTM :: forall b. Key StgArgMap -&gt; StgArgMap b -&gt; Maybe b
</span><a href="GHC.Data.TrieMap.html#lookupTM"><span class="hs-identifier hs-var hs-var hs-var hs-var">lookupTM</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621680955698"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955698"><span class="hs-identifier hs-var">var</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArgMap b -&gt; DVarEnv b
forall a. StgArgMap a -&gt; DVarEnv a
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var hs-var">sam_var</span></a></span><span> </span><span class="annot"><span class="annottext">(StgArgMap b -&gt; DVarEnv b)
-&gt; (DVarEnv b -&gt; Maybe b) -&gt; StgArgMap b -&gt; Maybe b
forall a b c. (a -&gt; b) -&gt; (b -&gt; c) -&gt; a -&gt; c
</span><a href="GHC.Data.TrieMap.html#%3E.%3E"><span class="hs-operator hs-var">&gt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; DVarEnv b -&gt; Maybe b
forall a. Id -&gt; DVarEnv a -&gt; Maybe a
</span><a href="GHC.Core.Map.html#lkDFreeVar"><span class="hs-identifier hs-var">lkDFreeVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955698"><span class="hs-identifier hs-var">var</span></a></span><span>
</span><span id="line-125"></span><span>    </span><span class="annot"><a href="GHC.Data.TrieMap.html#lookupTM"><span class="hs-identifier hs-var">lookupTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLitArg"><span class="hs-identifier hs-type">StgLitArg</span></a></span><span> </span><span id="local-6989586621680955694"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955694"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArgMap b -&gt; LiteralMap b
forall a. StgArgMap a -&gt; LiteralMap a
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var hs-var">sam_lit</span></a></span><span> </span><span class="annot"><span class="annottext">(StgArgMap b -&gt; LiteralMap b)
-&gt; (LiteralMap b -&gt; Maybe b) -&gt; StgArgMap b -&gt; Maybe b
forall a b c. (a -&gt; b) -&gt; (b -&gt; c) -&gt; a -&gt; c
</span><a href="GHC.Data.TrieMap.html#%3E.%3E"><span class="hs-operator hs-var">&gt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Key (Map Literal) -&gt; LiteralMap b -&gt; Maybe b
forall (m :: * -&gt; *) b. TrieMap m =&gt; Key m -&gt; m b -&gt; Maybe b
</span><a href="GHC.Data.TrieMap.html#lookupTM"><span class="hs-identifier hs-var">lookupTM</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
Key (Map Literal)
</span><a href="#local-6989586621680955694"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-126"></span><span>    </span><span id="local-6989586621680955691"><span class="annot"><span class="annottext">alterTM :: forall b. Key StgArgMap -&gt; XT b -&gt; StgArgMap b -&gt; StgArgMap b
</span><a href="GHC.Data.TrieMap.html#alterTM"><span class="hs-identifier hs-var hs-var hs-var hs-var">alterTM</span></a></span></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621680955689"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955689"><span class="hs-identifier hs-var">var</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680955688"><span class="annot"><span class="annottext">XT b
</span><a href="#local-6989586621680955688"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680955687"><span class="annot"><span class="annottext">StgArgMap b
</span><a href="#local-6989586621680955687"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArgMap b
</span><a href="#local-6989586621680955687"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sam_var :: DVarEnv b
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var">sam_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArgMap b -&gt; DVarEnv b
forall a. StgArgMap a -&gt; DVarEnv a
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var hs-var">sam_var</span></a></span><span> </span><span class="annot"><span class="annottext">StgArgMap b
</span><a href="#local-6989586621680955687"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">DVarEnv b -&gt; (DVarEnv b -&gt; DVarEnv b) -&gt; DVarEnv b
forall a b. a -&gt; (a -&gt; b) -&gt; b
</span><a href="GHC.Data.TrieMap.html#%7C%3E"><span class="hs-operator hs-var">|&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; XT b -&gt; DVarEnv b -&gt; DVarEnv b
forall a. Id -&gt; XT a -&gt; DVarEnv a -&gt; DVarEnv a
</span><a href="GHC.Core.Map.html#xtDFreeVar"><span class="hs-identifier hs-var">xtDFreeVar</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955689"><span class="hs-identifier hs-var">var</span></a></span><span> </span><span class="annot"><span class="annottext">XT b
</span><a href="#local-6989586621680955688"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-127"></span><span>    </span><span class="annot"><a href="GHC.Data.TrieMap.html#alterTM"><span class="hs-identifier hs-var">alterTM</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLitArg"><span class="hs-identifier hs-type">StgLitArg</span></a></span><span> </span><span id="local-6989586621680955684"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955684"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680955683"><span class="annot"><span class="annottext">XT b
</span><a href="#local-6989586621680955683"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680955682"><span class="annot"><span class="annottext">StgArgMap b
</span><a href="#local-6989586621680955682"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArgMap b
</span><a href="#local-6989586621680955682"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sam_lit :: LiteralMap b
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var">sam_lit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgArgMap b -&gt; LiteralMap b
forall a. StgArgMap a -&gt; LiteralMap a
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var hs-var">sam_lit</span></a></span><span> </span><span class="annot"><span class="annottext">StgArgMap b
</span><a href="#local-6989586621680955682"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">LiteralMap b -&gt; (LiteralMap b -&gt; LiteralMap b) -&gt; LiteralMap b
forall a b. a -&gt; (a -&gt; b) -&gt; b
</span><a href="GHC.Data.TrieMap.html#%7C%3E"><span class="hs-operator hs-var">|&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Key (Map Literal) -&gt; XT b -&gt; LiteralMap b -&gt; LiteralMap b
forall (m :: * -&gt; *) b. TrieMap m =&gt; Key m -&gt; XT b -&gt; m b -&gt; m b
</span><a href="GHC.Data.TrieMap.html#alterTM"><span class="hs-identifier hs-var">alterTM</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
Key (Map Literal)
</span><a href="#local-6989586621680955684"><span class="hs-identifier hs-var">lit</span></a></span><span> </span><span class="annot"><span class="annottext">XT b
</span><a href="#local-6989586621680955683"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-128"></span><span>    </span><span id="local-6989586621680955677"><span class="annot"><span class="annottext">foldTM :: forall a b. (a -&gt; b -&gt; b) -&gt; StgArgMap a -&gt; b -&gt; b
</span><a href="GHC.Data.TrieMap.html#foldTM"><span class="hs-identifier hs-var hs-var hs-var hs-var">foldTM</span></a></span></span><span> </span><span id="local-6989586621680955675"><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955675"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span id="local-6989586621680955674"><span class="annot"><span class="annottext">StgArgMap a
</span><a href="#local-6989586621680955674"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; b) -&gt; UniqDFM Id a -&gt; b -&gt; b
forall (m :: * -&gt; *) a b.
TrieMap m =&gt;
(a -&gt; b -&gt; b) -&gt; m a -&gt; b -&gt; b
</span><a href="GHC.Data.TrieMap.html#foldTM"><span class="hs-identifier hs-var">foldTM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955675"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StgArgMap a -&gt; UniqDFM Id a
forall a. StgArgMap a -&gt; DVarEnv a
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var hs-var">sam_var</span></a></span><span> </span><span class="annot"><span class="annottext">StgArgMap a
</span><a href="#local-6989586621680955674"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(b -&gt; b) -&gt; (b -&gt; b) -&gt; b -&gt; b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(a -&gt; b -&gt; b) -&gt; Map Literal a -&gt; b -&gt; b
forall (m :: * -&gt; *) a b.
TrieMap m =&gt;
(a -&gt; b -&gt; b) -&gt; m a -&gt; b -&gt; b
</span><a href="GHC.Data.TrieMap.html#foldTM"><span class="hs-identifier hs-var">foldTM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955675"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StgArgMap a -&gt; Map Literal a
forall a. StgArgMap a -&gt; LiteralMap a
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var hs-var">sam_lit</span></a></span><span> </span><span class="annot"><span class="annottext">StgArgMap a
</span><a href="#local-6989586621680955674"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>    </span><span id="local-6989586621680955668"><span class="annot"><span class="annottext">mapTM :: forall a b. (a -&gt; b) -&gt; StgArgMap a -&gt; StgArgMap b
</span><a href="GHC.Data.TrieMap.html#mapTM"><span class="hs-identifier hs-var hs-var hs-var hs-var">mapTM</span></a></span></span><span> </span><span id="local-6989586621680955666"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621680955666"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.CSE.html#SAM"><span class="hs-identifier hs-type">SAM</span></a></span><span> </span><span class="hs-special">{</span><span class="annot"><span class="annottext">sam_var :: forall a. StgArgMap a -&gt; DVarEnv a
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var">sam_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680955665"><span class="annot"><span class="annottext">DVarEnv a
</span><a href="#local-6989586621680955665"><span class="hs-identifier hs-var">varm</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sam_lit :: forall a. StgArgMap a -&gt; LiteralMap a
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var">sam_lit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621680955664"><span class="annot"><span class="annottext">LiteralMap a
</span><a href="#local-6989586621680955664"><span class="hs-identifier hs-var">litm</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-130"></span><span>        </span><span class="annot"><span class="annottext">SAM :: forall a. DVarEnv a -&gt; LiteralMap a -&gt; StgArgMap a
</span><a href="GHC.Stg.CSE.html#SAM"><span class="hs-identifier hs-type">SAM</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sam_var :: DVarEnv b
</span><a href="GHC.Stg.CSE.html#sam_var"><span class="hs-identifier hs-var">sam_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; DVarEnv a -&gt; DVarEnv b
forall (m :: * -&gt; *) a b. TrieMap m =&gt; (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="GHC.Data.TrieMap.html#mapTM"><span class="hs-identifier hs-var">mapTM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621680955666"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">DVarEnv a
</span><a href="#local-6989586621680955665"><span class="hs-identifier hs-var">varm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sam_lit :: LiteralMap b
</span><a href="GHC.Stg.CSE.html#sam_lit"><span class="hs-identifier hs-var">sam_lit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; LiteralMap a -&gt; LiteralMap b
forall (m :: * -&gt; *) a b. TrieMap m =&gt; (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="GHC.Data.TrieMap.html#mapTM"><span class="hs-identifier hs-var">mapTM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621680955666"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">LiteralMap a
</span><a href="#local-6989586621680955664"><span class="hs-identifier hs-var">litm</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-131"></span><span>
</span><span id="line-132"></span><span class="hs-keyword">newtype</span><span> </span><span id="ConAppMap"><span class="annot"><a href="GHC.Stg.CSE.html#ConAppMap"><span class="hs-identifier hs-var">ConAppMap</span></a></span></span><span> </span><span id="local-6989586621680955833"><span class="annot"><a href="#local-6989586621680955833"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="CAM"><span class="annot"><a href="GHC.Stg.CSE.html#CAM"><span class="hs-identifier hs-var">CAM</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="un_cam"><span class="annot"><span class="annottext">forall a. ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
</span><a href="GHC.Stg.CSE.html#un_cam"><span class="hs-identifier hs-var hs-var">un_cam</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.Env.html#DNameEnv"><span class="hs-identifier hs-type">DNameEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.TrieMap.html#ListMap"><span class="hs-identifier hs-type">ListMap</span></a></span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#StgArgMap"><span class="hs-identifier hs-type">StgArgMap</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680955833"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-133"></span><span>
</span><span id="line-134"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.Data.TrieMap.html#TrieMap"><span class="hs-identifier hs-type">TrieMap</span></a></span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#ConAppMap"><span class="hs-identifier hs-type">ConAppMap</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-135"></span><span>    </span><span class="hs-keyword">type</span><span> </span><span id="Key"><span class="annot"><a href="GHC.Data.TrieMap.html#Key"><span class="hs-identifier hs-var">Key</span></a></span></span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#ConAppMap"><span class="hs-identifier hs-type">ConAppMap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgArg"><span class="hs-identifier hs-type">StgArg</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-136"></span><span>    </span><span id="local-6989586621680955653"><span class="annot"><span class="annottext">emptyTM :: forall a. ConAppMap a
</span><a href="#local-6989586621680955653"><span class="hs-identifier hs-var hs-var hs-var hs-var">emptyTM</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DNameEnv (ListMap StgArgMap a) -&gt; ConAppMap a
forall a. DNameEnv (ListMap StgArgMap a) -&gt; ConAppMap a
</span><a href="GHC.Stg.CSE.html#CAM"><span class="hs-identifier hs-var">CAM</span></a></span><span> </span><span class="annot"><span class="annottext">DNameEnv (ListMap StgArgMap a)
forall (m :: * -&gt; *) a. TrieMap m =&gt; m a
</span><a href="GHC.Data.TrieMap.html#emptyTM"><span class="hs-identifier hs-var">emptyTM</span></a></span><span>
</span><span id="line-137"></span><span>    </span><span id="local-6989586621680955645"><span class="annot"><span class="annottext">lookupTM :: forall b. Key ConAppMap -&gt; ConAppMap b -&gt; Maybe b
</span><a href="#local-6989586621680955645"><span class="hs-identifier hs-var hs-var hs-var hs-var">lookupTM</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955644"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955644"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955643"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955643"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap b -&gt; DNameEnv (ListMap StgArgMap b)
forall a. ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
</span><a href="GHC.Stg.CSE.html#un_cam"><span class="hs-identifier hs-var hs-var">un_cam</span></a></span><span> </span><span class="annot"><span class="annottext">(ConAppMap b -&gt; DNameEnv (ListMap StgArgMap b))
-&gt; (DNameEnv (ListMap StgArgMap b) -&gt; Maybe b)
-&gt; ConAppMap b
-&gt; Maybe b
forall a b c. (a -&gt; b) -&gt; (b -&gt; c) -&gt; a -&gt; c
</span><a href="GHC.Data.TrieMap.html#%3E.%3E"><span class="hs-operator hs-var">&gt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
-&gt; DNameEnv (ListMap StgArgMap b) -&gt; Maybe (ListMap StgArgMap b)
forall n a. NamedThing n =&gt; n -&gt; DNameEnv a -&gt; Maybe a
</span><a href="GHC.Core.Map.html#lkDNamed"><span class="hs-identifier hs-var">lkDNamed</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955644"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">(DNameEnv (ListMap StgArgMap b) -&gt; Maybe (ListMap StgArgMap b))
-&gt; (ListMap StgArgMap b -&gt; Maybe b)
-&gt; DNameEnv (ListMap StgArgMap b)
-&gt; Maybe b
forall (m :: * -&gt; *) a b c.
Monad m =&gt;
(a -&gt; m b) -&gt; (b -&gt; m c) -&gt; a -&gt; m c
</span><a href="../../base/src/Control.Monad.html#%3E%3D%3E"><span class="hs-operator hs-var">&gt;=&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Key (ListMap StgArgMap) -&gt; ListMap StgArgMap b -&gt; Maybe b
forall (m :: * -&gt; *) b. TrieMap m =&gt; Key m -&gt; m b -&gt; Maybe b
</span><a href="GHC.Data.TrieMap.html#lookupTM"><span class="hs-identifier hs-var">lookupTM</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
Key (ListMap StgArgMap)
</span><a href="#local-6989586621680955643"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-138"></span><span>    </span><span id="local-6989586621680955637"><span class="annot"><span class="annottext">alterTM :: forall b. Key ConAppMap -&gt; XT b -&gt; ConAppMap b -&gt; ConAppMap b
</span><a href="#local-6989586621680955637"><span class="hs-identifier hs-var hs-var hs-var hs-var">alterTM</span></a></span></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621680955636"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955636"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955635"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955635"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680955634"><span class="annot"><span class="annottext">XT b
</span><a href="#local-6989586621680955634"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621680955633"><span class="annot"><span class="annottext">ConAppMap b
</span><a href="#local-6989586621680955633"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-139"></span><span>        </span><span class="annot"><span class="annottext">ConAppMap b
</span><a href="#local-6989586621680955633"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">un_cam :: DNameEnv (ListMap StgArgMap b)
</span><a href="GHC.Stg.CSE.html#un_cam"><span class="hs-identifier hs-var">un_cam</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap b -&gt; DNameEnv (ListMap StgArgMap b)
forall a. ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
</span><a href="GHC.Stg.CSE.html#un_cam"><span class="hs-identifier hs-var hs-var">un_cam</span></a></span><span> </span><span class="annot"><span class="annottext">ConAppMap b
</span><a href="#local-6989586621680955633"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">DNameEnv (ListMap StgArgMap b)
-&gt; (DNameEnv (ListMap StgArgMap b)
    -&gt; DNameEnv (ListMap StgArgMap b))
-&gt; DNameEnv (ListMap StgArgMap b)
forall a b. a -&gt; (a -&gt; b) -&gt; b
</span><a href="GHC.Data.TrieMap.html#%7C%3E"><span class="hs-operator hs-var">|&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
-&gt; XT (ListMap StgArgMap b)
-&gt; DNameEnv (ListMap StgArgMap b)
-&gt; DNameEnv (ListMap StgArgMap b)
forall n a. NamedThing n =&gt; n -&gt; XT a -&gt; DNameEnv a -&gt; DNameEnv a
</span><a href="GHC.Core.Map.html#xtDNamed"><span class="hs-identifier hs-var">xtDNamed</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955636"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">(XT (ListMap StgArgMap b)
 -&gt; DNameEnv (ListMap StgArgMap b)
 -&gt; DNameEnv (ListMap StgArgMap b))
-&gt; (ListMap StgArgMap b -&gt; ListMap StgArgMap b)
-&gt; DNameEnv (ListMap StgArgMap b)
-&gt; DNameEnv (ListMap StgArgMap b)
forall (m2 :: * -&gt; *) a (m1 :: * -&gt; *).
TrieMap m2 =&gt;
(XT (m2 a) -&gt; m1 (m2 a) -&gt; m1 (m2 a))
-&gt; (m2 a -&gt; m2 a) -&gt; m1 (m2 a) -&gt; m1 (m2 a)
</span><a href="GHC.Data.TrieMap.html#%7C%3E%3E"><span class="hs-operator hs-var">|&gt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Key (ListMap StgArgMap)
-&gt; XT b -&gt; ListMap StgArgMap b -&gt; ListMap StgArgMap b
forall (m :: * -&gt; *) b. TrieMap m =&gt; Key m -&gt; XT b -&gt; m b -&gt; m b
</span><a href="GHC.Data.TrieMap.html#alterTM"><span class="hs-identifier hs-var">alterTM</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
Key (ListMap StgArgMap)
</span><a href="#local-6989586621680955635"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">XT b
</span><a href="#local-6989586621680955634"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-140"></span><span>    </span><span id="local-6989586621680955626"><span class="annot"><span class="annottext">foldTM :: forall a b. (a -&gt; b -&gt; b) -&gt; ConAppMap a -&gt; b -&gt; b
</span><a href="#local-6989586621680955626"><span class="hs-identifier hs-var hs-var hs-var hs-var">foldTM</span></a></span></span><span> </span><span id="local-6989586621680955625"><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955625"><span class="hs-identifier hs-var">k</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
forall a. ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
</span><a href="GHC.Stg.CSE.html#un_cam"><span class="hs-identifier hs-var hs-var">un_cam</span></a></span><span> </span><span class="annot"><span class="annottext">(ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a))
-&gt; (DNameEnv (ListMap StgArgMap a) -&gt; b -&gt; b)
-&gt; ConAppMap a
-&gt; b
-&gt; b
forall a b c. (a -&gt; b) -&gt; (b -&gt; c) -&gt; a -&gt; c
</span><a href="GHC.Data.TrieMap.html#%3E.%3E"><span class="hs-operator hs-var">&gt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(ListMap StgArgMap a -&gt; b -&gt; b)
-&gt; DNameEnv (ListMap StgArgMap a) -&gt; b -&gt; b
forall (m :: * -&gt; *) a b.
TrieMap m =&gt;
(a -&gt; b -&gt; b) -&gt; m a -&gt; b -&gt; b
</span><a href="GHC.Data.TrieMap.html#foldTM"><span class="hs-identifier hs-var">foldTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b -&gt; b) -&gt; ListMap StgArgMap a -&gt; b -&gt; b
forall (m :: * -&gt; *) a b.
TrieMap m =&gt;
(a -&gt; b -&gt; b) -&gt; m a -&gt; b -&gt; b
</span><a href="GHC.Data.TrieMap.html#foldTM"><span class="hs-identifier hs-var">foldTM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955625"><span class="hs-identifier hs-var">k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-141"></span><span>    </span><span id="local-6989586621680955620"><span class="annot"><span class="annottext">mapTM :: forall a b. (a -&gt; b) -&gt; ConAppMap a -&gt; ConAppMap b
</span><a href="#local-6989586621680955620"><span class="hs-identifier hs-var hs-var hs-var hs-var">mapTM</span></a></span></span><span> </span><span id="local-6989586621680955619"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621680955619"><span class="hs-identifier hs-var">f</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
forall a. ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a)
</span><a href="GHC.Stg.CSE.html#un_cam"><span class="hs-identifier hs-var hs-var">un_cam</span></a></span><span> </span><span class="annot"><span class="annottext">(ConAppMap a -&gt; DNameEnv (ListMap StgArgMap a))
-&gt; (DNameEnv (ListMap StgArgMap a) -&gt; ConAppMap b)
-&gt; ConAppMap a
-&gt; ConAppMap b
forall a b c. (a -&gt; b) -&gt; (b -&gt; c) -&gt; a -&gt; c
</span><a href="GHC.Data.TrieMap.html#%3E.%3E"><span class="hs-operator hs-var">&gt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">(ListMap StgArgMap a -&gt; ListMap StgArgMap b)
-&gt; DNameEnv (ListMap StgArgMap a)
-&gt; UniqDFM Name (ListMap StgArgMap b)
forall (m :: * -&gt; *) a b. TrieMap m =&gt; (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="GHC.Data.TrieMap.html#mapTM"><span class="hs-identifier hs-var">mapTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; ListMap StgArgMap a -&gt; ListMap StgArgMap b
forall (m :: * -&gt; *) a b. TrieMap m =&gt; (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="GHC.Data.TrieMap.html#mapTM"><span class="hs-identifier hs-var">mapTM</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621680955619"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(DNameEnv (ListMap StgArgMap a)
 -&gt; UniqDFM Name (ListMap StgArgMap b))
-&gt; (UniqDFM Name (ListMap StgArgMap b) -&gt; ConAppMap b)
-&gt; DNameEnv (ListMap StgArgMap a)
-&gt; ConAppMap b
forall a b c. (a -&gt; b) -&gt; (b -&gt; c) -&gt; a -&gt; c
</span><a href="GHC.Data.TrieMap.html#%3E.%3E"><span class="hs-operator hs-var">&gt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">UniqDFM Name (ListMap StgArgMap b) -&gt; ConAppMap b
forall a. DNameEnv (ListMap StgArgMap a) -&gt; ConAppMap a
</span><a href="GHC.Stg.CSE.html#CAM"><span class="hs-identifier hs-var">CAM</span></a></span><span>
</span><span id="line-142"></span><span>
</span><span id="line-143"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-144"></span><span class="hs-comment">-- The CSE Env --</span><span>
</span><span id="line-145"></span><span class="hs-comment">-----------------</span><span>
</span><span id="line-146"></span><span>
</span><span id="line-147"></span><span class="hs-comment">-- | The CSE environment. See note [CseEnv Example]</span><span>
</span><span id="line-148"></span><span class="hs-keyword">data</span><span> </span><span id="CseEnv"><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-var">CseEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="CseEnv"><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-var">CseEnv</span></a></span></span><span>
</span><span id="line-149"></span><span>    </span><span class="hs-special">{</span><span> </span><span id="ce_conAppMap"><span class="annot"><span class="annottext">CseEnv -&gt; ConAppMap Id
</span><a href="GHC.Stg.CSE.html#ce_conAppMap"><span class="hs-identifier hs-var hs-var">ce_conAppMap</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#ConAppMap"><span class="hs-identifier hs-type">ConAppMap</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-150"></span><span>        </span><span class="hs-comment">-- ^ The main component of the environment is the trie that maps</span><span>
</span><span id="line-151"></span><span>        </span><span class="hs-comment">--   data constructor applications (with their `OutId` arguments)</span><span>
</span><span id="line-152"></span><span>        </span><span class="hs-comment">--   to an in-scope name that can be used instead.</span><span>
</span><span id="line-153"></span><span>        </span><span class="hs-comment">--   This name is always either a let-bound variable or a case binder.</span><span>
</span><span id="line-154"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="ce_subst"><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var hs-var">ce_subst</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-155"></span><span>        </span><span class="hs-comment">-- ^ This substitution is applied to the code as we traverse it.</span><span>
</span><span id="line-156"></span><span>        </span><span class="hs-comment">--   Entries have one of two reasons:</span><span>
</span><span id="line-157"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-158"></span><span>        </span><span class="hs-comment">--   * The input might have shadowing (see Note [Shadowing]), so we have</span><span>
</span><span id="line-159"></span><span>        </span><span class="hs-comment">--     to rename some binders as we traverse the tree.</span><span>
</span><span id="line-160"></span><span>        </span><span class="hs-comment">--   * If we remove `let x = Con z` because  `let y = Con z` is in scope,</span><span>
</span><span id="line-161"></span><span>        </span><span class="hs-comment">--     we note this here as x &#8614; y.</span><span>
</span><span id="line-162"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="ce_bndrMap"><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_bndrMap"><span class="hs-identifier hs-var hs-var">ce_bndrMap</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#IdEnv"><span class="hs-identifier hs-type">IdEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-163"></span><span>        </span><span class="hs-comment">-- ^ If we come across a case expression case x as b of &#8230; with a trivial</span><span>
</span><span id="line-164"></span><span>        </span><span class="hs-comment">--   binder, we add b &#8614; x to this.</span><span>
</span><span id="line-165"></span><span>        </span><span class="hs-comment">--   This map is *only* used when looking something up in the ce_conAppMap.</span><span>
</span><span id="line-166"></span><span>        </span><span class="hs-comment">--   See Note [Trivial case scrutinee]</span><span>
</span><span id="line-167"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="ce_in_scope"><span class="annot"><span class="annottext">CseEnv -&gt; InScopeSet
</span><a href="GHC.Stg.CSE.html#ce_in_scope"><span class="hs-identifier hs-var hs-var">ce_in_scope</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span>
</span><span id="line-168"></span><span>        </span><span class="hs-comment">-- ^ The third component is an in-scope set, to rename away any</span><span>
</span><span id="line-169"></span><span>        </span><span class="hs-comment">--   shadowing binders</span><span>
</span><span id="line-170"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-171"></span><span>
</span><span id="line-172"></span><span class="hs-comment">{-|
Note [CseEnv Example]
~~~~~~~~~~~~~~~~~~~~~
The following tables shows how the CseEnvironment changes as code is traversed,
as well as the changes to that code.

  InExpr                         OutExpr
     conAppMap                   subst          in_scope
  &#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;
  -- empty                       {}             {}
  case &#8230; as a of {Con x y -&gt;     case &#8230; as a of {Con x y -&gt;
  -- Con x y &#8614; a                 {}             {a,x,y}
  let b = Con x y                (removed)
  -- Con x y &#8614; a                 b&#8614;a            {a,x,y,b}
  let c = Bar a                  let c = Bar a
  -- Con x y &#8614; a, Bar a &#8614; c      b&#8614;a            {a,x,y,b,c}
  let c = some expression        let c' = some expression
  -- Con x y &#8614; a, Bar a &#8614; c      b&#8614;a, c&#8614;c',     {a,x,y,b,c,c'}
  let d = Bar b                  (removed)
  -- Con x y &#8614; a, Bar a &#8614; c      b&#8614;a, c&#8614;c', d&#8614;c {a,x,y,b,c,c',d}
  (a, b, c d)                    (a, a, c' c)
-}</span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="annot"><a href="GHC.Stg.CSE.html#initEnv"><span class="hs-identifier hs-type">initEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span>
</span><span id="line-196"></span><span id="initEnv"><span class="annot"><span class="annottext">initEnv :: InScopeSet -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#initEnv"><span class="hs-identifier hs-var hs-var">initEnv</span></a></span></span><span> </span><span id="local-6989586621680955611"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955611"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv :: ConAppMap Id -&gt; IdEnv Id -&gt; IdEnv Id -&gt; InScopeSet -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span>
</span><span id="line-197"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_conAppMap :: ConAppMap Id
</span><a href="GHC.Stg.CSE.html#ce_conAppMap"><span class="hs-identifier hs-var">ce_conAppMap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap Id
forall (m :: * -&gt; *) a. TrieMap m =&gt; m a
</span><a href="GHC.Data.TrieMap.html#emptyTM"><span class="hs-identifier hs-var">emptyTM</span></a></span><span>
</span><span id="line-198"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ce_subst :: IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var">ce_subst</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv Id
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-199"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ce_bndrMap :: IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_bndrMap"><span class="hs-identifier hs-var">ce_bndrMap</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv Id
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span>
</span><span id="line-200"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ce_in_scope :: InScopeSet
</span><a href="GHC.Stg.CSE.html#ce_in_scope"><span class="hs-identifier hs-var">ce_in_scope</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955611"><span class="hs-identifier hs-var">in_scope</span></a></span><span>
</span><span id="line-201"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-202"></span><span>
</span><span id="line-203"></span><span class="annot"><a href="GHC.Stg.CSE.html#envLookup"><span class="hs-identifier hs-type">envLookup</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgArg"><span class="hs-identifier hs-type">OutStgArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-204"></span><span id="envLookup"><span class="annot"><span class="annottext">envLookup :: DataCon -&gt; [StgArg] -&gt; CseEnv -&gt; Maybe Id
</span><a href="GHC.Stg.CSE.html#envLookup"><span class="hs-identifier hs-var hs-var">envLookup</span></a></span></span><span> </span><span id="local-6989586621680955607"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955607"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span> </span><span id="local-6989586621680955606"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955606"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621680955605"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955605"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Key ConAppMap -&gt; ConAppMap Id -&gt; Maybe Id
forall (m :: * -&gt; *) b. TrieMap m =&gt; Key m -&gt; m b -&gt; Maybe b
</span><a href="GHC.Data.TrieMap.html#lookupTM"><span class="hs-identifier hs-var">lookupTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955607"><span class="hs-identifier hs-var">dataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955604"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; ConAppMap Id
</span><a href="GHC.Stg.CSE.html#ce_conAppMap"><span class="hs-identifier hs-var hs-var">ce_conAppMap</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955605"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-205"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955604"><span class="annot"><span class="annottext">args' :: [StgArg]
</span><a href="#local-6989586621680955604"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(StgArg -&gt; StgArg) -&gt; [StgArg] -&gt; [StgArg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">StgArg -&gt; StgArg
</span><a href="#local-6989586621680955603"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955606"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="hs-comment">-- See Note [Trivial case scrutinee]</span><span>
</span><span id="line-206"></span><span>        </span><span id="local-6989586621680955603"><span class="annot"><span class="annottext">go :: StgArg -&gt; StgArg
</span><a href="#local-6989586621680955603"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621680955602"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955602"><span class="hs-identifier hs-var">v</span></a></span></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; StgArg
</span><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-var">StgVarArg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Maybe Id -&gt; Id
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955602"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Id -&gt; Id) -&gt; Maybe Id -&gt; Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv Id -&gt; Id -&gt; Maybe Id
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_bndrMap"><span class="hs-identifier hs-var hs-var">ce_bndrMap</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955605"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955602"><span class="hs-identifier hs-var">v</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-207"></span><span>        </span><span class="annot"><a href="#local-6989586621680955603"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLitArg"><span class="hs-identifier hs-type">StgLitArg</span></a></span><span> </span><span id="local-6989586621680955600"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955600"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; StgArg
</span><a href="GHC.Stg.Syntax.html#StgLitArg"><span class="hs-identifier hs-var">StgLitArg</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955600"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-208"></span><span>
</span><span id="line-209"></span><span class="annot"><a href="GHC.Stg.CSE.html#addDataCon"><span class="hs-identifier hs-type">addDataCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgArg"><span class="hs-identifier hs-type">OutStgArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span>
</span><span id="line-210"></span><span class="hs-comment">-- do not bother with nullary data constructors, they are static anyways</span><span>
</span><span id="line-211"></span><span id="addDataCon"><span class="annot"><span class="annottext">addDataCon :: Id -&gt; DataCon -&gt; [StgArg] -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addDataCon"><span class="hs-identifier hs-var hs-var">addDataCon</span></a></span></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span id="local-6989586621680955598"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955598"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955598"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-212"></span><span class="annot"><a href="GHC.Stg.CSE.html#addDataCon"><span class="hs-identifier hs-var">addDataCon</span></a></span><span> </span><span id="local-6989586621680955597"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955597"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680955596"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955596"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span> </span><span id="local-6989586621680955595"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955595"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621680955594"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955594"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955594"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_conAppMap :: ConAppMap Id
</span><a href="GHC.Stg.CSE.html#ce_conAppMap"><span class="hs-identifier hs-var">ce_conAppMap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap Id
</span><a href="#local-6989586621680955593"><span class="hs-identifier hs-var">new_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-213"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-214"></span><span>    </span><span id="local-6989586621680955593"><span class="annot"><span class="annottext">new_env :: ConAppMap Id
</span><a href="#local-6989586621680955593"><span class="hs-identifier hs-var hs-var">new_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Key ConAppMap -&gt; Id -&gt; ConAppMap Id -&gt; ConAppMap Id
forall (m :: * -&gt; *) a. TrieMap m =&gt; Key m -&gt; a -&gt; m a -&gt; m a
</span><a href="GHC.Data.TrieMap.html#insertTM"><span class="hs-identifier hs-var">insertTM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955596"><span class="hs-identifier hs-var">dataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955595"><span class="hs-identifier hs-var">args</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955597"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; ConAppMap Id
</span><a href="GHC.Stg.CSE.html#ce_conAppMap"><span class="hs-identifier hs-var hs-var">ce_conAppMap</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955594"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-215"></span><span>
</span><span id="line-216"></span><span class="annot"><a href="GHC.Stg.CSE.html#forgetCse"><span class="hs-identifier hs-type">forgetCse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span>
</span><span id="line-217"></span><span id="forgetCse"><span class="annot"><span class="annottext">forgetCse :: CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#forgetCse"><span class="hs-identifier hs-var hs-var">forgetCse</span></a></span></span><span> </span><span id="local-6989586621680955590"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955590"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955590"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_conAppMap :: ConAppMap Id
</span><a href="GHC.Stg.CSE.html#ce_conAppMap"><span class="hs-identifier hs-var">ce_conAppMap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConAppMap Id
forall (m :: * -&gt; *) a. TrieMap m =&gt; m a
</span><a href="GHC.Data.TrieMap.html#emptyTM"><span class="hs-identifier hs-var">emptyTM</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-218"></span><span>    </span><span class="hs-comment">-- See note [Free variables of an StgClosure]</span><span>
</span><span id="line-219"></span><span>
</span><span id="line-220"></span><span class="annot"><a href="GHC.Stg.CSE.html#addSubst"><span class="hs-identifier hs-type">addSubst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span>
</span><span id="line-221"></span><span id="addSubst"><span class="annot"><span class="annottext">addSubst :: Id -&gt; Id -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addSubst"><span class="hs-identifier hs-var hs-var">addSubst</span></a></span></span><span> </span><span id="local-6989586621680955588"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955588"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621680955587"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955587"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621680955586"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955586"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-222"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955586"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_subst :: IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var">ce_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv Id -&gt; Id -&gt; Id -&gt; IdEnv Id
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var hs-var">ce_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955586"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955588"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955587"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-223"></span><span>
</span><span id="line-224"></span><span class="annot"><a href="GHC.Stg.CSE.html#addTrivCaseBndr"><span class="hs-identifier hs-type">addTrivCaseBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span>
</span><span id="line-225"></span><span id="addTrivCaseBndr"><span class="annot"><span class="annottext">addTrivCaseBndr :: Id -&gt; Id -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addTrivCaseBndr"><span class="hs-identifier hs-var hs-var">addTrivCaseBndr</span></a></span></span><span> </span><span id="local-6989586621680955583"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955583"><span class="hs-identifier hs-var">from</span></a></span></span><span> </span><span id="local-6989586621680955582"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955582"><span class="hs-identifier hs-var">to</span></a></span></span><span> </span><span id="local-6989586621680955581"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955581"><span class="hs-identifier hs-var">env</span></a></span></span><span>
</span><span id="line-226"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955581"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_bndrMap :: IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_bndrMap"><span class="hs-identifier hs-var">ce_bndrMap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv Id -&gt; Id -&gt; Id -&gt; IdEnv Id
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_bndrMap"><span class="hs-identifier hs-var hs-var">ce_bndrMap</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955581"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955583"><span class="hs-identifier hs-var">from</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955582"><span class="hs-identifier hs-var">to</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-227"></span><span>
</span><span id="line-228"></span><span class="annot"><a href="GHC.Stg.CSE.html#substArgs"><span class="hs-identifier hs-type">substArgs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgArg"><span class="hs-identifier hs-type">InStgArg</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgArg"><span class="hs-identifier hs-type">OutStgArg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-229"></span><span id="substArgs"><span class="annot"><span class="annottext">substArgs :: CseEnv -&gt; [StgArg] -&gt; [StgArg]
</span><a href="GHC.Stg.CSE.html#substArgs"><span class="hs-identifier hs-var hs-var">substArgs</span></a></span></span><span> </span><span id="local-6989586621680955578"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955578"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(StgArg -&gt; StgArg) -&gt; [StgArg] -&gt; [StgArg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; StgArg -&gt; StgArg
</span><a href="GHC.Stg.CSE.html#substArg"><span class="hs-identifier hs-var">substArg</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955578"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-230"></span><span>
</span><span id="line-231"></span><span class="annot"><a href="GHC.Stg.CSE.html#substArg"><span class="hs-identifier hs-type">substArg</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgArg"><span class="hs-identifier hs-type">InStgArg</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgArg"><span class="hs-identifier hs-type">OutStgArg</span></a></span><span>
</span><span id="line-232"></span><span id="substArg"><span class="annot"><span class="annottext">substArg :: CseEnv -&gt; StgArg -&gt; StgArg
</span><a href="GHC.Stg.CSE.html#substArg"><span class="hs-identifier hs-var hs-var">substArg</span></a></span></span><span> </span><span id="local-6989586621680955576"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955576"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-type">StgVarArg</span></a></span><span> </span><span id="local-6989586621680955575"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955575"><span class="hs-identifier hs-var">from</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; StgArg
</span><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-var">StgVarArg</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; Id
</span><a href="GHC.Stg.CSE.html#substVar"><span class="hs-identifier hs-var">substVar</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955576"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955575"><span class="hs-identifier hs-var">from</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-233"></span><span class="annot"><a href="GHC.Stg.CSE.html#substArg"><span class="hs-identifier hs-var">substArg</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><span class="hs-identifier">_</span></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLitArg"><span class="hs-identifier hs-type">StgLitArg</span></a></span><span> </span><span id="local-6989586621680955573"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955573"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; StgArg
</span><a href="GHC.Stg.Syntax.html#StgLitArg"><span class="hs-identifier hs-var">StgLitArg</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955573"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-234"></span><span>
</span><span id="line-235"></span><span class="annot"><a href="GHC.Stg.CSE.html#substVar"><span class="hs-identifier hs-type">substVar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span>
</span><span id="line-236"></span><span id="substVar"><span class="annot"><span class="annottext">substVar :: CseEnv -&gt; Id -&gt; Id
</span><a href="GHC.Stg.CSE.html#substVar"><span class="hs-identifier hs-var hs-var">substVar</span></a></span></span><span> </span><span id="local-6989586621680955571"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955571"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955570"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955570"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Maybe Id -&gt; Id
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955570"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Id -&gt; Id) -&gt; Maybe Id -&gt; Id
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">IdEnv Id -&gt; Id -&gt; Maybe Id
forall a. VarEnv a -&gt; Id -&gt; Maybe a
</span><a href="GHC.Types.Var.Env.html#lookupVarEnv"><span class="hs-identifier hs-var">lookupVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var hs-var">ce_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955571"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955570"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span class="hs-comment">-- Functions to enter binders</span><span>
</span><span id="line-239"></span><span>
</span><span id="line-240"></span><span class="hs-comment">-- This is much simpler than the equivalent code in GHC.Core.Subst:</span><span>
</span><span id="line-241"></span><span class="hs-comment">--  * We do not substitute type variables, and</span><span>
</span><span id="line-242"></span><span class="hs-comment">--  * There is nothing relevant in GHC.Types.Id.Info at this stage</span><span>
</span><span id="line-243"></span><span class="hs-comment">--    that needs substitutions.</span><span>
</span><span id="line-244"></span><span class="hs-comment">-- Therefore, no special treatment for a recursive group is required.</span><span>
</span><span id="line-245"></span><span>
</span><span id="line-246"></span><span class="annot"><a href="GHC.Stg.CSE.html#substBndr"><span class="hs-identifier hs-type">substBndr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#InId"><span class="hs-identifier hs-type">InId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-247"></span><span id="substBndr"><span class="annot"><span class="annottext">substBndr :: CseEnv -&gt; Id -&gt; (CseEnv, Id)
</span><a href="GHC.Stg.CSE.html#substBndr"><span class="hs-identifier hs-var hs-var">substBndr</span></a></span></span><span> </span><span id="local-6989586621680955568"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955568"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955567"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955567"><span class="hs-identifier hs-var">old_id</span></a></span></span><span>
</span><span id="line-248"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955566"><span class="hs-identifier hs-var">new_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955565"><span class="hs-identifier hs-var">new_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-249"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-250"></span><span>    </span><span id="local-6989586621680955565"><span class="annot"><span class="annottext">new_id :: Id
</span><a href="#local-6989586621680955565"><span class="hs-identifier hs-var hs-var">new_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; Id
</span><a href="GHC.Types.Var.Env.html#uniqAway"><span class="hs-identifier hs-var">uniqAway</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; InScopeSet
</span><a href="GHC.Stg.CSE.html#ce_in_scope"><span class="hs-identifier hs-var hs-var">ce_in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955568"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955567"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-251"></span><span>    </span><span id="local-6989586621680955563"><span class="annot"><span class="annottext">no_change :: Bool
</span><a href="#local-6989586621680955563"><span class="hs-identifier hs-var hs-var">no_change</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955565"><span class="hs-identifier hs-var">new_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955567"><span class="hs-identifier hs-var">old_id</span></a></span><span>
</span><span id="line-252"></span><span>    </span><span id="local-6989586621680955562"><span class="annot"><span class="annottext">env' :: CseEnv
</span><a href="#local-6989586621680955562"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955568"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_in_scope :: InScopeSet
</span><a href="GHC.Stg.CSE.html#ce_in_scope"><span class="hs-identifier hs-var">ce_in_scope</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; InScopeSet
</span><a href="GHC.Stg.CSE.html#ce_in_scope"><span class="hs-identifier hs-var hs-var">ce_in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955568"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955565"><span class="hs-identifier hs-var">new_id</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-253"></span><span>    </span><span id="local-6989586621680955566"><span class="annot"><span class="annottext">new_env :: CseEnv
</span><a href="#local-6989586621680955566"><span class="hs-identifier hs-var hs-var">new_env</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621680955563"><span class="hs-identifier hs-var">no_change</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955562"><span class="hs-identifier hs-var">env'</span></a></span><span>
</span><span id="line-254"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955562"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ce_subst :: IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var">ce_subst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdEnv Id -&gt; Id -&gt; Id -&gt; IdEnv Id
forall a. VarEnv a -&gt; Id -&gt; a -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#extendVarEnv"><span class="hs-identifier hs-var">extendVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; IdEnv Id
</span><a href="GHC.Stg.CSE.html#ce_subst"><span class="hs-identifier hs-var hs-var">ce_subst</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955568"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955567"><span class="hs-identifier hs-var">old_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955565"><span class="hs-identifier hs-var">new_id</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-255"></span><span>
</span><span id="line-256"></span><span class="annot"><a href="GHC.Stg.CSE.html#substBndrs"><span class="hs-identifier hs-type">substBndrs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-257"></span><span id="substBndrs"><span class="annot"><span class="annottext">substBndrs :: CseEnv -&gt; [Id] -&gt; (CseEnv, [Id])
</span><a href="GHC.Stg.CSE.html#substBndrs"><span class="hs-identifier hs-var hs-var">substBndrs</span></a></span></span><span> </span><span id="local-6989586621680955557"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955557"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955556"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680955556"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CseEnv -&gt; Id -&gt; (CseEnv, Id)) -&gt; CseEnv -&gt; [Id] -&gt; (CseEnv, [Id])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; (CseEnv, Id)
</span><a href="GHC.Stg.CSE.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955557"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680955556"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-258"></span><span>
</span><span id="line-259"></span><span id="local-6989586621680955787"><span class="annot"><a href="GHC.Stg.CSE.html#substPairs"><span class="hs-identifier hs-type">substPairs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#InVar"><span class="hs-identifier hs-type">InVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680955787"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutVar"><span class="hs-identifier hs-type">OutVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621680955787"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span></span><span>
</span><span id="line-260"></span><span id="substPairs"><span class="annot"><span class="annottext">substPairs :: forall a. CseEnv -&gt; [(Id, a)] -&gt; (CseEnv, [(Id, a)])
</span><a href="GHC.Stg.CSE.html#substPairs"><span class="hs-identifier hs-var hs-var">substPairs</span></a></span></span><span> </span><span id="local-6989586621680955553"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955553"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955552"><span class="annot"><span class="annottext">[(Id, a)]
</span><a href="#local-6989586621680955552"><span class="hs-identifier hs-var">bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(CseEnv -&gt; (Id, a) -&gt; (CseEnv, (Id, a)))
-&gt; CseEnv -&gt; [(Id, a)] -&gt; (CseEnv, [(Id, a)])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; (Id, a) -&gt; (CseEnv, (Id, a))
forall {b}. CseEnv -&gt; (Id, b) -&gt; (CseEnv, (Id, b))
</span><a href="#local-6989586621680955551"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955553"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, a)]
</span><a href="#local-6989586621680955552"><span class="hs-identifier hs-var">bndrs</span></a></span><span>
</span><span id="line-261"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955551"><span class="annot"><span class="annottext">go :: CseEnv -&gt; (Id, b) -&gt; (CseEnv, (Id, b))
</span><a href="#local-6989586621680955551"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621680955550"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955550"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955549"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955549"><span class="hs-identifier hs-var">id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955548"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680955548"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955547"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955547"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955546"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955546"><span class="hs-identifier hs-var">id'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; (CseEnv, Id)
</span><a href="GHC.Stg.CSE.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955550"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955549"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-262"></span><span>                         </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955547"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955546"><span class="hs-identifier hs-var">id'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680955548"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-comment">-- Main entry point</span><span>
</span><span id="line-265"></span><span>
</span><span id="line-266"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCse"><span class="hs-identifier hs-type">stgCse</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgTopBinding"><span class="hs-identifier hs-type">InStgTopBinding</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgTopBinding"><span class="hs-identifier hs-type">OutStgTopBinding</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-267"></span><span id="stgCse"><span class="annot"><span class="annottext">stgCse :: [InStgTopBinding] -&gt; [InStgTopBinding]
</span><a href="GHC.Stg.CSE.html#stgCse"><span class="hs-identifier hs-var hs-var">stgCse</span></a></span></span><span> </span><span id="local-6989586621680955544"><span class="annot"><span class="annottext">[InStgTopBinding]
</span><a href="#local-6989586621680955544"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InScopeSet, [InStgTopBinding]) -&gt; [InStgTopBinding]
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span> </span><span class="annot"><span class="annottext">((InScopeSet, [InStgTopBinding]) -&gt; [InStgTopBinding])
-&gt; (InScopeSet, [InStgTopBinding]) -&gt; [InStgTopBinding]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">(InScopeSet -&gt; InStgTopBinding -&gt; (InScopeSet, InStgTopBinding))
-&gt; InScopeSet
-&gt; [InStgTopBinding]
-&gt; (InScopeSet, [InStgTopBinding])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; InStgTopBinding -&gt; (InScopeSet, InStgTopBinding)
</span><a href="GHC.Stg.CSE.html#stgCseTopLvl"><span class="hs-identifier hs-var">stgCseTopLvl</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="GHC.Types.Var.Env.html#emptyInScopeSet"><span class="hs-identifier hs-var">emptyInScopeSet</span></a></span><span> </span><span class="annot"><span class="annottext">[InStgTopBinding]
</span><a href="#local-6989586621680955544"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span class="hs-comment">-- Top level bindings.</span><span>
</span><span id="line-270"></span><span class="hs-comment">--</span><span>
</span><span id="line-271"></span><span class="hs-comment">-- We do not CSE these, as top-level closures are allocated statically anyways.</span><span>
</span><span id="line-272"></span><span class="hs-comment">-- Also, they might be exported.</span><span>
</span><span id="line-273"></span><span class="hs-comment">-- But we still have to collect the set of in-scope variables, otherwise</span><span>
</span><span id="line-274"></span><span class="hs-comment">-- uniqAway might shadow a top-level closure.</span><span>
</span><span id="line-275"></span><span>
</span><span id="line-276"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseTopLvl"><span class="hs-identifier hs-type">stgCseTopLvl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgTopBinding"><span class="hs-identifier hs-type">InStgTopBinding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgTopBinding"><span class="hs-identifier hs-type">OutStgTopBinding</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-277"></span><span id="stgCseTopLvl"><span class="annot"><span class="annottext">stgCseTopLvl :: InScopeSet -&gt; InStgTopBinding -&gt; (InScopeSet, InStgTopBinding)
</span><a href="GHC.Stg.CSE.html#stgCseTopLvl"><span class="hs-identifier hs-var hs-var">stgCseTopLvl</span></a></span></span><span> </span><span id="local-6989586621680955541"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955541"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span id="local-6989586621680955540"><span class="annot"><span class="annottext">t :: InStgTopBinding
</span><a href="#local-6989586621680955540"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgTopStringLit"><span class="hs-identifier hs-type">StgTopStringLit</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">ByteString
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955541"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InStgTopBinding
</span><a href="#local-6989586621680955540"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-278"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseTopLvl"><span class="hs-identifier hs-var">stgCseTopLvl</span></a></span><span> </span><span id="local-6989586621680955538"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955538"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgTopLifted"><span class="hs-identifier hs-type">StgTopLifted</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgNonRec"><span class="hs-identifier hs-type">StgNonRec</span></a></span><span> </span><span id="local-6989586621680955535"><span class="annot"><span class="annottext">BinderP 'Vanilla
</span><a href="#local-6989586621680955535"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680955534"><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955534"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955533"><span class="hs-identifier hs-var">in_scope'</span></a></span><span>
</span><span id="line-280"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'Vanilla -&gt; InStgTopBinding
forall (pass :: StgPass).
GenStgBinding pass -&gt; GenStgTopBinding pass
</span><a href="GHC.Stg.Syntax.html#StgTopLifted"><span class="hs-identifier hs-var">StgTopLifted</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BinderP 'Vanilla -&gt; GenStgRhs 'Vanilla -&gt; GenStgBinding 'Vanilla
forall (pass :: StgPass).
BinderP pass -&gt; GenStgRhs pass -&gt; GenStgBinding pass
</span><a href="GHC.Stg.Syntax.html#StgNonRec"><span class="hs-identifier hs-var">StgNonRec</span></a></span><span> </span><span class="annot"><span class="annottext">BinderP 'Vanilla
</span><a href="#local-6989586621680955535"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; GenStgRhs 'Vanilla -&gt; GenStgRhs 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseTopLvlRhs"><span class="hs-identifier hs-var">stgCseTopLvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955538"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955534"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-281"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955533"><span class="annot"><span class="annottext">in_scope' :: InScopeSet
</span><a href="#local-6989586621680955533"><span class="hs-identifier hs-var hs-var">in_scope'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955538"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; Id -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSet"><span class="hs-operator hs-var">`extendInScopeSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955535"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-282"></span><span>
</span><span id="line-283"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseTopLvl"><span class="hs-identifier hs-var">stgCseTopLvl</span></a></span><span> </span><span id="local-6989586621680955531"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955531"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgTopLifted"><span class="hs-identifier hs-type">StgTopLifted</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRec"><span class="hs-identifier hs-type">StgRec</span></a></span><span> </span><span id="local-6989586621680955529"><span class="annot"><span class="annottext">[(BinderP 'Vanilla, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955529"><span class="hs-identifier hs-var">eqs</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-284"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955528"><span class="hs-identifier hs-var">in_scope'</span></a></span><span>
</span><span id="line-285"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'Vanilla -&gt; InStgTopBinding
forall (pass :: StgPass).
GenStgBinding pass -&gt; GenStgTopBinding pass
</span><a href="GHC.Stg.Syntax.html#StgTopLifted"><span class="hs-identifier hs-var">StgTopLifted</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(BinderP 'Vanilla, GenStgRhs 'Vanilla)] -&gt; GenStgBinding 'Vanilla
forall (pass :: StgPass).
[(BinderP pass, GenStgRhs pass)] -&gt; GenStgBinding pass
</span><a href="GHC.Stg.Syntax.html#StgRec"><span class="hs-identifier hs-var">StgRec</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955527"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; GenStgRhs 'Vanilla -&gt; GenStgRhs 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseTopLvlRhs"><span class="hs-identifier hs-var">stgCseTopLvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955528"><span class="hs-identifier hs-var">in_scope'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955526"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955527"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955527"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955526"><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955526"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
[(BinderP 'Vanilla, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955529"><span class="hs-identifier hs-var">eqs</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-286"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955528"><span class="annot"><span class="annottext">in_scope' :: InScopeSet
</span><a href="#local-6989586621680955528"><span class="hs-identifier hs-var hs-var">in_scope'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955531"><span class="hs-identifier hs-var">in_scope</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; [Id] -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#extendInScopeSetList"><span class="hs-operator hs-var">`extendInScopeSetList`</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955524"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955524"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955524"><span class="hs-identifier hs-var">bndr</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
[(BinderP 'Vanilla, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955529"><span class="hs-identifier hs-var">eqs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-287"></span><span>
</span><span id="line-288"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseTopLvlRhs"><span class="hs-identifier hs-type">stgCseTopLvlRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#InScopeSet"><span class="hs-identifier hs-type">InScopeSet</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgRhs"><span class="hs-identifier hs-type">InStgRhs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgRhs"><span class="hs-identifier hs-type">OutStgRhs</span></a></span><span>
</span><span id="line-289"></span><span id="stgCseTopLvlRhs"><span class="annot"><span class="annottext">stgCseTopLvlRhs :: InScopeSet -&gt; GenStgRhs 'Vanilla -&gt; GenStgRhs 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseTopLvlRhs"><span class="hs-identifier hs-var hs-var">stgCseTopLvlRhs</span></a></span></span><span> </span><span id="local-6989586621680955521"><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955521"><span class="hs-identifier hs-var">in_scope</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRhsClosure"><span class="hs-identifier hs-type">StgRhsClosure</span></a></span><span> </span><span id="local-6989586621680955519"><span class="annot"><span class="annottext">XRhsClosure 'Vanilla
</span><a href="#local-6989586621680955519"><span class="hs-identifier hs-var">ext</span></a></span></span><span> </span><span id="local-6989586621680955518"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955518"><span class="hs-identifier hs-var">ccs</span></a></span></span><span> </span><span id="local-6989586621680955517"><span class="annot"><span class="annottext">UpdateFlag
</span><a href="#local-6989586621680955517"><span class="hs-identifier hs-var">upd</span></a></span></span><span> </span><span id="local-6989586621680955516"><span class="annot"><span class="annottext">[BinderP 'Vanilla]
</span><a href="#local-6989586621680955516"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621680955515"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955515"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-290"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680955514"><span class="annot"><span class="annottext">body' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955514"><span class="hs-identifier hs-var hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InScopeSet -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#initEnv"><span class="hs-identifier hs-var">initEnv</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><a href="#local-6989586621680955521"><span class="hs-identifier hs-var">in_scope</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955515"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-291"></span><span>      </span><span class="hs-keyword">in</span><span>  </span><span class="annot"><span class="annottext">XRhsClosure 'Vanilla
-&gt; CostCentreStack
-&gt; UpdateFlag
-&gt; [BinderP 'Vanilla]
-&gt; GenStgExpr 'Vanilla
-&gt; GenStgRhs 'Vanilla
forall (pass :: StgPass).
XRhsClosure pass
-&gt; CostCentreStack
-&gt; UpdateFlag
-&gt; [BinderP pass]
-&gt; GenStgExpr pass
-&gt; GenStgRhs pass
</span><a href="GHC.Stg.Syntax.html#StgRhsClosure"><span class="hs-identifier hs-var">StgRhsClosure</span></a></span><span> </span><span class="annot"><span class="annottext">XRhsClosure 'Vanilla
</span><a href="#local-6989586621680955519"><span class="hs-identifier hs-var">ext</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955518"><span class="hs-identifier hs-var">ccs</span></a></span><span> </span><span class="annot"><span class="annottext">UpdateFlag
</span><a href="#local-6989586621680955517"><span class="hs-identifier hs-var">upd</span></a></span><span> </span><span class="annot"><span class="annottext">[BinderP 'Vanilla]
</span><a href="#local-6989586621680955516"><span class="hs-identifier hs-var">args</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955514"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-292"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseTopLvlRhs"><span class="hs-identifier hs-var">stgCseTopLvlRhs</span></a></span><span> </span><span class="annot"><span class="annottext">InScopeSet
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRhsCon"><span class="hs-identifier hs-type">StgRhsCon</span></a></span><span> </span><span id="local-6989586621680955511"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955511"><span class="hs-identifier hs-var">ccs</span></a></span></span><span> </span><span id="local-6989586621680955510"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955510"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span> </span><span id="local-6989586621680955509"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955509"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CostCentreStack -&gt; DataCon -&gt; [StgArg] -&gt; GenStgRhs 'Vanilla
forall (pass :: StgPass).
CostCentreStack -&gt; DataCon -&gt; [StgArg] -&gt; GenStgRhs pass
</span><a href="GHC.Stg.Syntax.html#StgRhsCon"><span class="hs-identifier hs-var">StgRhsCon</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955511"><span class="hs-identifier hs-var">ccs</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955510"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955509"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-296"></span><span class="hs-comment">-- The actual AST traversal --</span><span>
</span><span id="line-297"></span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-298"></span><span>
</span><span id="line-299"></span><span class="hs-comment">-- Trivial cases</span><span>
</span><span id="line-300"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-type">stgCseExpr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgExpr"><span class="hs-identifier hs-type">InStgExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgExpr"><span class="hs-identifier hs-type">OutStgExpr</span></a></span><span>
</span><span id="line-301"></span><span id="stgCseExpr"><span class="annot"><span class="annottext">stgCseExpr :: CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var hs-var">stgCseExpr</span></a></span></span><span> </span><span id="local-6989586621680955506"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955506"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621680955504"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955504"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621680955503"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955503"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-302"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [StgArg] -&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass). Id -&gt; [StgArg] -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-var">StgApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955502"><span class="hs-identifier hs-var">fun'</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955501"><span class="hs-identifier hs-var">args'</span></a></span><span>
</span><span id="line-303"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955502"><span class="annot"><span class="annottext">fun' :: Id
</span><a href="#local-6989586621680955502"><span class="hs-identifier hs-var hs-var">fun'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; Id
</span><a href="GHC.Stg.CSE.html#substVar"><span class="hs-identifier hs-var">substVar</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955506"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955504"><span class="hs-identifier hs-var">fun</span></a></span><span>
</span><span id="line-304"></span><span>        </span><span id="local-6989586621680955501"><span class="annot"><span class="annottext">args' :: [StgArg]
</span><a href="#local-6989586621680955501"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [StgArg] -&gt; [StgArg]
</span><a href="GHC.Stg.CSE.html#substArgs"><span class="hs-identifier hs-var">substArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955506"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955503"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-305"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLit"><span class="hs-identifier hs-type">StgLit</span></a></span><span> </span><span id="local-6989586621680955499"><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955499"><span class="hs-identifier hs-var">lit</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-306"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Literal -&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass). Literal -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgLit"><span class="hs-identifier hs-var">StgLit</span></a></span><span> </span><span class="annot"><span class="annottext">Literal
</span><a href="#local-6989586621680955499"><span class="hs-identifier hs-var">lit</span></a></span><span>
</span><span id="line-307"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span id="local-6989586621680955498"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955498"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-type">StgOpApp</span></a></span><span> </span><span id="local-6989586621680955496"><span class="annot"><span class="annottext">StgOp
</span><a href="#local-6989586621680955496"><span class="hs-identifier hs-var">op</span></a></span></span><span> </span><span id="local-6989586621680955495"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955495"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621680955494"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680955494"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-308"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StgOp -&gt; [StgArg] -&gt; Type -&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass).
StgOp -&gt; [StgArg] -&gt; Type -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgOpApp"><span class="hs-identifier hs-var">StgOpApp</span></a></span><span> </span><span class="annot"><span class="annottext">StgOp
</span><a href="#local-6989586621680955496"><span class="hs-identifier hs-var">op</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955493"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621680955494"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-309"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955493"><span class="annot"><span class="annottext">args' :: [StgArg]
</span><a href="#local-6989586621680955493"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [StgArg] -&gt; [StgArg]
</span><a href="GHC.Stg.CSE.html#substArgs"><span class="hs-identifier hs-var">substArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955498"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955495"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-310"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLam"><span class="hs-identifier hs-type">StgLam</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty (BinderP 'Vanilla)
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>
</span><span id="line-311"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; GenStgExpr 'Vanilla
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;stgCseExp&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;StgLam&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-312"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span id="local-6989586621680955489"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955489"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgTick"><span class="hs-identifier hs-type">StgTick</span></a></span><span> </span><span id="local-6989586621680955487"><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680955487"><span class="hs-identifier hs-var">tick</span></a></span></span><span> </span><span id="local-6989586621680955486"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955486"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-313"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680955485"><span class="annot"><span class="annottext">body' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955485"><span class="hs-identifier hs-var hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955489"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955486"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-314"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Tickish Id -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass).
Tickish Id -&gt; GenStgExpr pass -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgTick"><span class="hs-identifier hs-var">StgTick</span></a></span><span> </span><span class="annot"><span class="annottext">Tickish Id
</span><a href="#local-6989586621680955487"><span class="hs-identifier hs-var">tick</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955485"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-315"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span id="local-6989586621680955484"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955484"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgCase"><span class="hs-identifier hs-type">StgCase</span></a></span><span> </span><span id="local-6989586621680955482"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955482"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680955481"><span class="annot"><span class="annottext">BinderP 'Vanilla
</span><a href="#local-6989586621680955481"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680955480"><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955480"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680955479"><span class="annot"><span class="annottext">[GenStgAlt 'Vanilla]
</span><a href="#local-6989586621680955479"><span class="hs-identifier hs-var">alts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-316"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
-&gt; Id -&gt; AltType -&gt; [GenStgAlt 'Vanilla] -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#mkStgCase"><span class="hs-identifier hs-var">mkStgCase</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955477"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955476"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955480"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(AltCon, [Id], GenStgExpr 'Vanilla)]
[GenStgAlt 'Vanilla]
</span><a href="#local-6989586621680955475"><span class="hs-identifier hs-var">alts'</span></a></span><span>
</span><span id="line-317"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-318"></span><span>    </span><span id="local-6989586621680955477"><span class="annot"><span class="annottext">scrut' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955477"><span class="hs-identifier hs-var hs-var">scrut'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955484"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955482"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-319"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621680955474"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955474"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955476"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955476"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; (CseEnv, Id)
</span><a href="GHC.Stg.CSE.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955484"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955481"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-320"></span><span>    </span><span id="local-6989586621680955473"><span class="annot"><span class="annottext">env2 :: CseEnv
</span><a href="#local-6989586621680955473"><span class="hs-identifier hs-var hs-var">env2</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621680955472"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955472"><span class="hs-identifier hs-var">trivial_scrut</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955477"><span class="hs-identifier hs-var">scrut'</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addTrivCaseBndr"><span class="hs-identifier hs-var">addTrivCaseBndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955481"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955472"><span class="hs-identifier hs-var">trivial_scrut</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955474"><span class="hs-identifier hs-var">env1</span></a></span><span>
</span><span id="line-321"></span><span>                 </span><span class="hs-comment">-- See Note [Trivial case scrutinee]</span><span>
</span><span id="line-322"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955474"><span class="hs-identifier hs-var">env1</span></a></span><span>
</span><span id="line-323"></span><span>    </span><span id="local-6989586621680955475"><span class="annot"><span class="annottext">alts' :: [(AltCon, [Id], GenStgExpr 'Vanilla)]
</span><a href="#local-6989586621680955475"><span class="hs-identifier hs-var hs-var">alts'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((AltCon, [Id], GenStgExpr 'Vanilla)
 -&gt; (AltCon, [Id], GenStgExpr 'Vanilla))
-&gt; [(AltCon, [Id], GenStgExpr 'Vanilla)]
-&gt; [(AltCon, [Id], GenStgExpr 'Vanilla)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; AltType -&gt; Id -&gt; GenStgAlt 'Vanilla -&gt; GenStgAlt 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseAlt"><span class="hs-identifier hs-var">stgCseAlt</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955473"><span class="hs-identifier hs-var">env2</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955480"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955476"><span class="hs-identifier hs-var">bndr'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(AltCon, [Id], GenStgExpr 'Vanilla)]
[GenStgAlt 'Vanilla]
</span><a href="#local-6989586621680955479"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-324"></span><span>
</span><span id="line-325"></span><span>
</span><span id="line-326"></span><span class="hs-comment">-- A constructor application.</span><span>
</span><span id="line-327"></span><span class="hs-comment">-- To be removed by a variable use when found in the CSE environment</span><span>
</span><span id="line-328"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span id="local-6989586621680955470"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955470"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgConApp"><span class="hs-identifier hs-type">StgConApp</span></a></span><span> </span><span id="local-6989586621680955468"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955468"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span> </span><span id="local-6989586621680955467"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955467"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621680955466"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680955466"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-329"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680955465"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955465"><span class="hs-identifier hs-var">bndr'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [StgArg] -&gt; CseEnv -&gt; Maybe Id
</span><a href="GHC.Stg.CSE.html#envLookup"><span class="hs-identifier hs-var">envLookup</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955468"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955464"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955470"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-330"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [StgArg] -&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass). Id -&gt; [StgArg] -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-var">StgApp</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955465"><span class="hs-identifier hs-var">bndr'</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-331"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-332"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [StgArg] -&gt; [Type] -&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass).
DataCon -&gt; [StgArg] -&gt; [Type] -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgConApp"><span class="hs-identifier hs-var">StgConApp</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955468"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955464"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621680955466"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-333"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955464"><span class="annot"><span class="annottext">args' :: [StgArg]
</span><a href="#local-6989586621680955464"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [StgArg] -&gt; [StgArg]
</span><a href="GHC.Stg.CSE.html#substArgs"><span class="hs-identifier hs-var">substArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955470"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955467"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-334"></span><span>
</span><span id="line-335"></span><span class="hs-comment">-- Let bindings</span><span>
</span><span id="line-336"></span><span class="hs-comment">-- The binding might be removed due to CSE (we do not want trivial bindings on</span><span>
</span><span id="line-337"></span><span class="hs-comment">-- the STG level), so use the smart constructor `mkStgLet` to remove the binding</span><span>
</span><span id="line-338"></span><span class="hs-comment">-- if empty.</span><span>
</span><span id="line-339"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span id="local-6989586621680955463"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955463"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLet"><span class="hs-identifier hs-type">StgLet</span></a></span><span> </span><span id="local-6989586621680955461"><span class="annot"><span class="annottext">XLet 'Vanilla
</span><a href="#local-6989586621680955461"><span class="hs-identifier hs-var">ext</span></a></span></span><span> </span><span id="local-6989586621680955460"><span class="annot"><span class="annottext">GenStgBinding 'Vanilla
</span><a href="#local-6989586621680955460"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621680955459"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955459"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-340"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955458"><span class="annot"><span class="annottext">Maybe (GenStgBinding 'Vanilla)
</span><a href="#local-6989586621680955458"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955457"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955457"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; GenStgBinding 'Vanilla
-&gt; (Maybe (GenStgBinding 'Vanilla), CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCseBind"><span class="hs-identifier hs-var">stgCseBind</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955463"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'Vanilla
</span><a href="#local-6989586621680955460"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-341"></span><span>          </span><span id="local-6989586621680955455"><span class="annot"><span class="annottext">body' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955455"><span class="hs-identifier hs-var hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955457"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955459"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-342"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(GenStgBinding 'Vanilla
 -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla)
-&gt; Maybe (GenStgBinding 'Vanilla)
-&gt; GenStgExpr 'Vanilla
-&gt; GenStgExpr 'Vanilla
forall a b. (a -&gt; b -&gt; b) -&gt; Maybe a -&gt; b -&gt; b
</span><a href="GHC.Stg.CSE.html#mkStgLet"><span class="hs-identifier hs-var">mkStgLet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XLet 'Vanilla
-&gt; GenStgBinding 'Vanilla
-&gt; GenStgExpr 'Vanilla
-&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass).
XLet pass
-&gt; GenStgBinding pass -&gt; GenStgExpr pass -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgLet"><span class="hs-identifier hs-var">StgLet</span></a></span><span> </span><span class="annot"><span class="annottext">XLet 'Vanilla
</span><a href="#local-6989586621680955461"><span class="hs-identifier hs-var">ext</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe (GenStgBinding 'Vanilla)
</span><a href="#local-6989586621680955458"><span class="hs-identifier hs-var">binds'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955455"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-343"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span id="local-6989586621680955453"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955453"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgLetNoEscape"><span class="hs-identifier hs-type">StgLetNoEscape</span></a></span><span> </span><span id="local-6989586621680955451"><span class="annot"><span class="annottext">XLetNoEscape 'Vanilla
</span><a href="#local-6989586621680955451"><span class="hs-identifier hs-var">ext</span></a></span></span><span> </span><span id="local-6989586621680955450"><span class="annot"><span class="annottext">GenStgBinding 'Vanilla
</span><a href="#local-6989586621680955450"><span class="hs-identifier hs-var">binds</span></a></span></span><span> </span><span id="local-6989586621680955449"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955449"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-344"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955448"><span class="annot"><span class="annottext">Maybe (GenStgBinding 'Vanilla)
</span><a href="#local-6989586621680955448"><span class="hs-identifier hs-var">binds'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955447"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955447"><span class="hs-identifier hs-var">env'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; GenStgBinding 'Vanilla
-&gt; (Maybe (GenStgBinding 'Vanilla), CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCseBind"><span class="hs-identifier hs-var">stgCseBind</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955453"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgBinding 'Vanilla
</span><a href="#local-6989586621680955450"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-345"></span><span>          </span><span id="local-6989586621680955446"><span class="annot"><span class="annottext">body' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955446"><span class="hs-identifier hs-var hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955447"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955449"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-346"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(GenStgBinding 'Vanilla
 -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla)
-&gt; Maybe (GenStgBinding 'Vanilla)
-&gt; GenStgExpr 'Vanilla
-&gt; GenStgExpr 'Vanilla
forall a b. (a -&gt; b -&gt; b) -&gt; Maybe a -&gt; b -&gt; b
</span><a href="GHC.Stg.CSE.html#mkStgLet"><span class="hs-identifier hs-var">mkStgLet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XLetNoEscape 'Vanilla
-&gt; GenStgBinding 'Vanilla
-&gt; GenStgExpr 'Vanilla
-&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass).
XLetNoEscape pass
-&gt; GenStgBinding pass -&gt; GenStgExpr pass -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgLetNoEscape"><span class="hs-identifier hs-var">StgLetNoEscape</span></a></span><span> </span><span class="annot"><span class="annottext">XLetNoEscape 'Vanilla
</span><a href="#local-6989586621680955451"><span class="hs-identifier hs-var">ext</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Maybe (GenStgBinding 'Vanilla)
</span><a href="#local-6989586621680955448"><span class="hs-identifier hs-var">binds'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955446"><span class="hs-identifier hs-var">body'</span></a></span><span>
</span><span id="line-347"></span><span>
</span><span id="line-348"></span><span class="hs-comment">-- Case alternatives</span><span>
</span><span id="line-349"></span><span class="hs-comment">-- Extend the CSE environment</span><span>
</span><span id="line-350"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseAlt"><span class="hs-identifier hs-type">stgCseAlt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#AltType"><span class="hs-identifier hs-type">AltType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgAlt"><span class="hs-identifier hs-type">InStgAlt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgAlt"><span class="hs-identifier hs-type">OutStgAlt</span></a></span><span>
</span><span id="line-351"></span><span id="stgCseAlt"><span class="annot"><span class="annottext">stgCseAlt :: CseEnv -&gt; AltType -&gt; Id -&gt; GenStgAlt 'Vanilla -&gt; GenStgAlt 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseAlt"><span class="hs-identifier hs-var hs-var">stgCseAlt</span></a></span></span><span> </span><span id="local-6989586621680955443"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955443"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955442"><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955442"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680955441"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955441"><span class="hs-identifier hs-var">case_bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-type">DataAlt</span></a></span><span> </span><span id="local-6989586621680955439"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955439"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955438"><span class="annot"><span class="annottext">[BinderP 'Vanilla]
</span><a href="#local-6989586621680955438"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955437"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955437"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-352"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955436"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955436"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955435"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680955435"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [Id] -&gt; (CseEnv, [Id])
</span><a href="GHC.Stg.CSE.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955443"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'Vanilla]
</span><a href="#local-6989586621680955438"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-353"></span><span>          </span><span id="local-6989586621680955434"><span class="annot"><span class="annottext">env2 :: CseEnv
</span><a href="#local-6989586621680955434"><span class="hs-identifier hs-var hs-var">env2</span></a></span></span><span>
</span><span id="line-354"></span><span>            </span><span class="hs-comment">-- To avoid dealing with unboxed sums StgCse runs after unarise and</span><span>
</span><span id="line-355"></span><span>            </span><span class="hs-comment">-- should maintain invariants listed in Note [Post-unarisation</span><span>
</span><span id="line-356"></span><span>            </span><span class="hs-comment">-- invariants]. One of the invariants is that some binders are not</span><span>
</span><span id="line-357"></span><span>            </span><span class="hs-comment">-- used (unboxed tuple case binders) which is what we check with</span><span>
</span><span id="line-358"></span><span>            </span><span class="hs-comment">-- `stgCaseBndrInScope` here. If the case binder is not in scope we</span><span>
</span><span id="line-359"></span><span>            </span><span class="hs-comment">-- don't add it to the CSE env. See also #15300.</span><span>
</span><span id="line-360"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">AltType -&gt; Bool -&gt; Bool
</span><a href="GHC.Stg.Syntax.html#stgCaseBndrInScope"><span class="hs-identifier hs-var">stgCaseBndrInScope</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955442"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-comment">-- CSE runs after unarise</span><span>
</span><span id="line-361"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; DataCon -&gt; [StgArg] -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addDataCon"><span class="hs-identifier hs-var">addDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955441"><span class="hs-identifier hs-var">case_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955439"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; StgArg) -&gt; [Id] -&gt; [StgArg]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; StgArg
</span><a href="GHC.Stg.Syntax.html#StgVarArg"><span class="hs-identifier hs-var">StgVarArg</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680955435"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955436"><span class="hs-identifier hs-var">env1</span></a></span><span>
</span><span id="line-362"></span><span>            </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-363"></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955436"><span class="hs-identifier hs-var">env1</span></a></span><span>
</span><span id="line-364"></span><span>            </span><span class="hs-comment">-- see note [Case 2: CSEing case binders]</span><span>
</span><span id="line-365"></span><span>          </span><span id="local-6989586621680955432"><span class="annot"><span class="annottext">rhs' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955432"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955434"><span class="hs-identifier hs-var">env2</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955437"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-366"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; AltCon
</span><a href="GHC.Core.html#DataAlt"><span class="hs-identifier hs-var">DataAlt</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955439"><span class="hs-identifier hs-var">dataCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'Vanilla]
</span><a href="#local-6989586621680955435"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955432"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-367"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseAlt"><span class="hs-identifier hs-var">stgCseAlt</span></a></span><span> </span><span id="local-6989586621680955431"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955431"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="annot"><span class="annottext">AltType
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955430"><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680955430"><span class="hs-identifier hs-var">altCon</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955429"><span class="annot"><span class="annottext">[BinderP 'Vanilla]
</span><a href="#local-6989586621680955429"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955428"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955428"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-368"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955427"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955427"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955426"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680955426"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [Id] -&gt; (CseEnv, [Id])
</span><a href="GHC.Stg.CSE.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955431"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'Vanilla]
</span><a href="#local-6989586621680955429"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-369"></span><span>          </span><span id="local-6989586621680955425"><span class="annot"><span class="annottext">rhs' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955425"><span class="hs-identifier hs-var hs-var">rhs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955427"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955428"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-370"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><a href="#local-6989586621680955430"><span class="hs-identifier hs-var">altCon</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'Vanilla]
</span><a href="#local-6989586621680955426"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955425"><span class="hs-identifier hs-var">rhs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-371"></span><span>
</span><span id="line-372"></span><span class="hs-comment">-- Bindings</span><span>
</span><span id="line-373"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseBind"><span class="hs-identifier hs-type">stgCseBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgBinding"><span class="hs-identifier hs-type">InStgBinding</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgBinding"><span class="hs-identifier hs-type">OutStgBinding</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-374"></span><span id="stgCseBind"><span class="annot"><span class="annottext">stgCseBind :: CseEnv
-&gt; GenStgBinding 'Vanilla
-&gt; (Maybe (GenStgBinding 'Vanilla), CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCseBind"><span class="hs-identifier hs-var hs-var">stgCseBind</span></a></span></span><span> </span><span id="local-6989586621680955422"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955422"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgNonRec"><span class="hs-identifier hs-type">StgNonRec</span></a></span><span> </span><span id="local-6989586621680955421"><span class="annot"><span class="annottext">BinderP 'Vanilla
</span><a href="#local-6989586621680955421"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span id="local-6989586621680955420"><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955420"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-375"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955419"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955419"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955418"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955418"><span class="hs-identifier hs-var">b'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; (CseEnv, Id)
</span><a href="GHC.Stg.CSE.html#substBndr"><span class="hs-identifier hs-var">substBndr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955422"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955421"><span class="hs-identifier hs-var">b</span></a></span><span>
</span><span id="line-376"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; Id
-&gt; GenStgRhs 'Vanilla
-&gt; (Maybe (Id, GenStgRhs 'Vanilla), CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCseRhs"><span class="hs-identifier hs-var">stgCseRhs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955419"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955418"><span class="hs-identifier hs-var">b'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955420"><span class="hs-identifier hs-var">e</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-377"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Id, GenStgRhs 'Vanilla)
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>      </span><span id="local-6989586621680955416"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955416"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (GenStgBinding 'Vanilla)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>                </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955416"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-378"></span><span>        </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955415"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955415"><span class="hs-identifier hs-var">b2</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680955414"><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955414"><span class="hs-identifier hs-var">e'</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955413"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955413"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenStgBinding 'Vanilla -&gt; Maybe (GenStgBinding 'Vanilla)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">BinderP 'Vanilla -&gt; GenStgRhs 'Vanilla -&gt; GenStgBinding 'Vanilla
forall (pass :: StgPass).
BinderP pass -&gt; GenStgRhs pass -&gt; GenStgBinding pass
</span><a href="GHC.Stg.Syntax.html#StgNonRec"><span class="hs-identifier hs-var">StgNonRec</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955415"><span class="hs-identifier hs-var">b2</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955414"><span class="hs-identifier hs-var">e'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955413"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-379"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseBind"><span class="hs-identifier hs-var">stgCseBind</span></a></span><span> </span><span id="local-6989586621680955412"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955412"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRec"><span class="hs-identifier hs-type">StgRec</span></a></span><span> </span><span id="local-6989586621680955411"><span class="annot"><span class="annottext">[(BinderP 'Vanilla, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955411"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-380"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955410"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955410"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955409"><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955409"><span class="hs-identifier hs-var">pairs1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; [(Id, GenStgRhs 'Vanilla)]
-&gt; (CseEnv, [(Id, GenStgRhs 'Vanilla)])
forall a. CseEnv -&gt; [(Id, a)] -&gt; (CseEnv, [(Id, a)])
</span><a href="GHC.Stg.CSE.html#substPairs"><span class="hs-identifier hs-var">substPairs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955412"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
[(BinderP 'Vanilla, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955411"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-381"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; [(Id, GenStgRhs 'Vanilla)]
-&gt; ([(Id, GenStgRhs 'Vanilla)], CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCsePairs"><span class="hs-identifier hs-var">stgCsePairs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955410"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955409"><span class="hs-identifier hs-var">pairs1</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-382"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span>     </span><span id="local-6989586621680955407"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955407"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (GenStgBinding 'Vanilla)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955407"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-383"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680955406"><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955406"><span class="hs-identifier hs-var">pairs2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955405"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955405"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenStgBinding 'Vanilla -&gt; Maybe (GenStgBinding 'Vanilla)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(BinderP 'Vanilla, GenStgRhs 'Vanilla)] -&gt; GenStgBinding 'Vanilla
forall (pass :: StgPass).
[(BinderP pass, GenStgRhs pass)] -&gt; GenStgBinding pass
</span><a href="GHC.Stg.Syntax.html#StgRec"><span class="hs-identifier hs-var">StgRec</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
[(BinderP 'Vanilla, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955406"><span class="hs-identifier hs-var">pairs2</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955405"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-384"></span><span>
</span><span id="line-385"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCsePairs"><span class="hs-identifier hs-type">stgCsePairs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgRhs"><span class="hs-identifier hs-type">InStgRhs</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgRhs"><span class="hs-identifier hs-type">OutStgRhs</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-386"></span><span id="stgCsePairs"><span class="annot"><span class="annottext">stgCsePairs :: CseEnv
-&gt; [(Id, GenStgRhs 'Vanilla)]
-&gt; ([(Id, GenStgRhs 'Vanilla)], CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCsePairs"><span class="hs-identifier hs-var hs-var">stgCsePairs</span></a></span></span><span> </span><span id="local-6989586621680955404"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955404"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955404"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-387"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCsePairs"><span class="hs-identifier hs-var">stgCsePairs</span></a></span><span> </span><span id="local-6989586621680955403"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955403"><span class="hs-identifier hs-var">env0</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621680955402"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955402"><span class="hs-identifier hs-var">b</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621680955401"><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955401"><span class="hs-identifier hs-var">e</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621680955400"><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955400"><span class="hs-identifier hs-var">pairs</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-388"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955399"><span class="annot"><span class="annottext">Maybe (Id, GenStgRhs 'Vanilla)
</span><a href="#local-6989586621680955399"><span class="hs-identifier hs-var">pairMB</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955398"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955398"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; Id
-&gt; GenStgRhs 'Vanilla
-&gt; (Maybe (Id, GenStgRhs 'Vanilla), CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCseRhs"><span class="hs-identifier hs-var">stgCseRhs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955403"><span class="hs-identifier hs-var">env0</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955402"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgRhs 'Vanilla
</span><a href="#local-6989586621680955401"><span class="hs-identifier hs-var">e</span></a></span><span>
</span><span id="line-389"></span><span>        </span><span class="hs-special">(</span><span id="local-6989586621680955397"><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955397"><span class="hs-identifier hs-var">pairs'</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955396"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955396"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv
-&gt; [(Id, GenStgRhs 'Vanilla)]
-&gt; ([(Id, GenStgRhs 'Vanilla)], CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCsePairs"><span class="hs-identifier hs-var">stgCsePairs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955398"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955400"><span class="hs-identifier hs-var">pairs</span></a></span><span>
</span><span id="line-390"></span><span>    </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Id, GenStgRhs 'Vanilla)
</span><a href="#local-6989586621680955399"><span class="hs-identifier hs-var">pairMB</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Id, GenStgRhs 'Vanilla)
-&gt; [(Id, GenStgRhs 'Vanilla)] -&gt; [(Id, GenStgRhs 'Vanilla)]
forall {a}. Maybe a -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621680955395"><span class="hs-operator hs-var">`mbCons`</span></a></span><span> </span><span class="annot"><span class="annottext">[(Id, GenStgRhs 'Vanilla)]
</span><a href="#local-6989586621680955397"><span class="hs-identifier hs-var">pairs'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955396"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-391"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-392"></span><span>    </span><span id="local-6989586621680955395"><span class="annot"><span class="annottext">mbCons :: Maybe a -&gt; [a] -&gt; [a]
</span><a href="#local-6989586621680955395"><span class="hs-identifier hs-var hs-var">mbCons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([a] -&gt; [a]) -&gt; (a -&gt; [a] -&gt; [a]) -&gt; Maybe a -&gt; [a] -&gt; [a]
forall b a. b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b
</span><a href="../../base/src/Data.Maybe.html#maybe"><span class="hs-identifier hs-var">maybe</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -&gt; [a]
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">:</span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>
</span><span id="line-394"></span><span class="hs-comment">-- The RHS of a binding.</span><span>
</span><span id="line-395"></span><span class="hs-comment">-- If it is a constructor application, either short-cut it or extend the environment</span><span>
</span><span id="line-396"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseRhs"><span class="hs-identifier hs-type">stgCseRhs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#InStgRhs"><span class="hs-identifier hs-type">InStgRhs</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#OutStgRhs"><span class="hs-identifier hs-type">OutStgRhs</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.CSE.html#CseEnv"><span class="hs-identifier hs-type">CseEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-397"></span><span id="stgCseRhs"><span class="annot"><span class="annottext">stgCseRhs :: CseEnv
-&gt; Id
-&gt; GenStgRhs 'Vanilla
-&gt; (Maybe (Id, GenStgRhs 'Vanilla), CseEnv)
</span><a href="GHC.Stg.CSE.html#stgCseRhs"><span class="hs-identifier hs-var hs-var">stgCseRhs</span></a></span></span><span> </span><span id="local-6989586621680955392"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955392"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955391"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955391"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRhsCon"><span class="hs-identifier hs-type">StgRhsCon</span></a></span><span> </span><span id="local-6989586621680955390"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955390"><span class="hs-identifier hs-var">ccs</span></a></span></span><span> </span><span id="local-6989586621680955389"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955389"><span class="hs-identifier hs-var">dataCon</span></a></span></span><span> </span><span id="local-6989586621680955388"><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955388"><span class="hs-identifier hs-var">args</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-398"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680955387"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955387"><span class="hs-identifier hs-var">other_bndr</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [StgArg] -&gt; CseEnv -&gt; Maybe Id
</span><a href="GHC.Stg.CSE.html#envLookup"><span class="hs-identifier hs-var">envLookup</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955389"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955386"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955392"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-399"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccInfo -&gt; Bool
</span><a href="GHC.Types.Basic.html#isWeakLoopBreaker"><span class="hs-identifier hs-var">isWeakLoopBreaker</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; OccInfo
</span><a href="GHC.Types.Id.html#idOccInfo"><span class="hs-identifier hs-var">idOccInfo</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955391"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- See Note [Care with loop breakers]</span><span>
</span><span id="line-400"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680955383"><span class="annot"><span class="annottext">env' :: CseEnv
</span><a href="#local-6989586621680955383"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addSubst"><span class="hs-identifier hs-var">addSubst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955391"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955387"><span class="hs-identifier hs-var">other_bndr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955392"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-401"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Id, GenStgRhs 'Vanilla)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955383"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-402"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-403"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621680955382"><span class="annot"><span class="annottext">env' :: CseEnv
</span><a href="#local-6989586621680955382"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; DataCon -&gt; [StgArg] -&gt; CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#addDataCon"><span class="hs-identifier hs-var">addDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955391"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955389"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955386"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955392"><span class="hs-identifier hs-var">env</span></a></span><span>
</span><span id="line-404"></span><span>            </span><span class="hs-comment">-- see note [Case 1: CSEing allocated closures]</span><span>
</span><span id="line-405"></span><span>          </span><span id="local-6989586621680955381"><span class="annot"><span class="annottext">pair :: (Id, GenStgRhs 'Vanilla)
</span><a href="#local-6989586621680955381"><span class="hs-identifier hs-var hs-var">pair</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955391"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CostCentreStack -&gt; DataCon -&gt; [StgArg] -&gt; GenStgRhs 'Vanilla
forall (pass :: StgPass).
CostCentreStack -&gt; DataCon -&gt; [StgArg] -&gt; GenStgRhs pass
</span><a href="GHC.Stg.Syntax.html#StgRhsCon"><span class="hs-identifier hs-var">StgRhsCon</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955390"><span class="hs-identifier hs-var">ccs</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621680955389"><span class="hs-identifier hs-var">dataCon</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955386"><span class="hs-identifier hs-var">args'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-406"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id, GenStgRhs 'Vanilla) -&gt; Maybe (Id, GenStgRhs 'Vanilla)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(Id, GenStgRhs 'Vanilla)
</span><a href="#local-6989586621680955381"><span class="hs-identifier hs-var">pair</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955382"><span class="hs-identifier hs-var">env'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-407"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621680955386"><span class="annot"><span class="annottext">args' :: [StgArg]
</span><a href="#local-6989586621680955386"><span class="hs-identifier hs-var hs-var">args'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [StgArg] -&gt; [StgArg]
</span><a href="GHC.Stg.CSE.html#substArgs"><span class="hs-identifier hs-var">substArgs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955392"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[StgArg]
</span><a href="#local-6989586621680955388"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span class="annot"><a href="GHC.Stg.CSE.html#stgCseRhs"><span class="hs-identifier hs-var">stgCseRhs</span></a></span><span> </span><span id="local-6989586621680955380"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955380"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span id="local-6989586621680955379"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955379"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgRhsClosure"><span class="hs-identifier hs-type">StgRhsClosure</span></a></span><span> </span><span id="local-6989586621680955378"><span class="annot"><span class="annottext">XRhsClosure 'Vanilla
</span><a href="#local-6989586621680955378"><span class="hs-identifier hs-var">ext</span></a></span></span><span> </span><span id="local-6989586621680955377"><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955377"><span class="hs-identifier hs-var">ccs</span></a></span></span><span> </span><span id="local-6989586621680955376"><span class="annot"><span class="annottext">UpdateFlag
</span><a href="#local-6989586621680955376"><span class="hs-identifier hs-var">upd</span></a></span></span><span> </span><span id="local-6989586621680955375"><span class="annot"><span class="annottext">[BinderP 'Vanilla]
</span><a href="#local-6989586621680955375"><span class="hs-identifier hs-var">args</span></a></span></span><span> </span><span id="local-6989586621680955374"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955374"><span class="hs-identifier hs-var">body</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-410"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621680955373"><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955373"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621680955372"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621680955372"><span class="hs-identifier hs-var">args'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; [Id] -&gt; (CseEnv, [Id])
</span><a href="GHC.Stg.CSE.html#substBndrs"><span class="hs-identifier hs-var">substBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955380"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'Vanilla]
</span><a href="#local-6989586621680955375"><span class="hs-identifier hs-var">args</span></a></span><span>
</span><span id="line-411"></span><span>          </span><span id="local-6989586621680955371"><span class="annot"><span class="annottext">env2 :: CseEnv
</span><a href="#local-6989586621680955371"><span class="hs-identifier hs-var hs-var">env2</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; CseEnv
</span><a href="GHC.Stg.CSE.html#forgetCse"><span class="hs-identifier hs-var">forgetCse</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955373"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="hs-comment">-- See note [Free variables of an StgClosure]</span><span>
</span><span id="line-412"></span><span>          </span><span id="local-6989586621680955370"><span class="annot"><span class="annottext">body' :: GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955370"><span class="hs-identifier hs-var hs-var">body'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CseEnv -&gt; GenStgExpr 'Vanilla -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#stgCseExpr"><span class="hs-identifier hs-var">stgCseExpr</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955371"><span class="hs-identifier hs-var">env2</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955374"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-413"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id, GenStgRhs 'Vanilla) -&gt; Maybe (Id, GenStgRhs 'Vanilla)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CseEnv -&gt; Id -&gt; Id
</span><a href="GHC.Stg.CSE.html#substVar"><span class="hs-identifier hs-var">substVar</span></a></span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955380"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955379"><span class="hs-identifier hs-var">bndr</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">XRhsClosure 'Vanilla
-&gt; CostCentreStack
-&gt; UpdateFlag
-&gt; [BinderP 'Vanilla]
-&gt; GenStgExpr 'Vanilla
-&gt; GenStgRhs 'Vanilla
forall (pass :: StgPass).
XRhsClosure pass
-&gt; CostCentreStack
-&gt; UpdateFlag
-&gt; [BinderP pass]
-&gt; GenStgExpr pass
-&gt; GenStgRhs pass
</span><a href="GHC.Stg.Syntax.html#StgRhsClosure"><span class="hs-identifier hs-var">StgRhsClosure</span></a></span><span> </span><span class="annot"><span class="annottext">XRhsClosure 'Vanilla
</span><a href="#local-6989586621680955378"><span class="hs-identifier hs-var">ext</span></a></span><span> </span><span class="annot"><span class="annottext">CostCentreStack
</span><a href="#local-6989586621680955377"><span class="hs-identifier hs-var">ccs</span></a></span><span> </span><span class="annot"><span class="annottext">UpdateFlag
</span><a href="#local-6989586621680955376"><span class="hs-identifier hs-var">upd</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[BinderP 'Vanilla]
</span><a href="#local-6989586621680955372"><span class="hs-identifier hs-var">args'</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955370"><span class="hs-identifier hs-var">body'</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CseEnv
</span><a href="#local-6989586621680955380"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-414"></span><span>
</span><span id="line-415"></span><span>
</span><span id="line-416"></span><span class="annot"><a href="GHC.Stg.CSE.html#mkStgCase"><span class="hs-identifier hs-type">mkStgCase</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgExpr"><span class="hs-identifier hs-type">StgExpr</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#OutId"><span class="hs-identifier hs-type">OutId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#AltType"><span class="hs-identifier hs-type">AltType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Stg.Syntax.html#StgAlt"><span class="hs-identifier hs-type">StgAlt</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgExpr"><span class="hs-identifier hs-type">StgExpr</span></a></span><span>
</span><span id="line-417"></span><span id="mkStgCase"><span class="annot"><span class="annottext">mkStgCase :: GenStgExpr 'Vanilla
-&gt; Id -&gt; AltType -&gt; [GenStgAlt 'Vanilla] -&gt; GenStgExpr 'Vanilla
</span><a href="GHC.Stg.CSE.html#mkStgCase"><span class="hs-identifier hs-var hs-var">mkStgCase</span></a></span></span><span> </span><span id="local-6989586621680955367"><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955367"><span class="hs-identifier hs-var">scrut</span></a></span></span><span> </span><span id="local-6989586621680955366"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955366"><span class="hs-identifier hs-var">bndr</span></a></span></span><span> </span><span id="local-6989586621680955365"><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955365"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span id="local-6989586621680955364"><span class="annot"><span class="annottext">[GenStgAlt 'Vanilla]
</span><a href="#local-6989586621680955364"><span class="hs-identifier hs-var">alts</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">((AltCon, [Id], GenStgExpr 'Vanilla) -&gt; Bool)
-&gt; [(AltCon, [Id], GenStgExpr 'Vanilla)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">(AltCon, [Id], GenStgExpr 'Vanilla) -&gt; Bool
</span><a href="#local-6989586621680955362"><span class="hs-identifier hs-var">isBndr</span></a></span><span> </span><span class="annot"><span class="annottext">[(AltCon, [Id], GenStgExpr 'Vanilla)]
[GenStgAlt 'Vanilla]
</span><a href="#local-6989586621680955364"><span class="hs-identifier hs-var">alts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955367"><span class="hs-identifier hs-var">scrut</span></a></span><span>
</span><span id="line-418"></span><span>                             </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
-&gt; BinderP 'Vanilla
-&gt; AltType
-&gt; [GenStgAlt 'Vanilla]
-&gt; GenStgExpr 'Vanilla
forall (pass :: StgPass).
GenStgExpr pass
-&gt; BinderP pass -&gt; AltType -&gt; [GenStgAlt pass] -&gt; GenStgExpr pass
</span><a href="GHC.Stg.Syntax.html#StgCase"><span class="hs-identifier hs-var">StgCase</span></a></span><span> </span><span class="annot"><span class="annottext">GenStgExpr 'Vanilla
</span><a href="#local-6989586621680955367"><span class="hs-identifier hs-var">scrut</span></a></span><span> </span><span class="annot"><span class="annottext">Id
BinderP 'Vanilla
</span><a href="#local-6989586621680955366"><span class="hs-identifier hs-var">bndr</span></a></span><span> </span><span class="annot"><span class="annottext">AltType
</span><a href="#local-6989586621680955365"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="annot"><span class="annottext">[GenStgAlt 'Vanilla]
</span><a href="#local-6989586621680955364"><span class="hs-identifier hs-var">alts</span></a></span><span>
</span><span id="line-419"></span><span>
</span><span id="line-420"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-421"></span><span>    </span><span class="hs-comment">-- see Note [All alternatives are the binder]</span><span>
</span><span id="line-422"></span><span>    </span><span id="local-6989586621680955362"><span class="annot"><span class="annottext">isBndr :: (AltCon, [Id], GenStgExpr 'Vanilla) -&gt; Bool
</span><a href="#local-6989586621680955362"><span class="hs-identifier hs-var hs-var">isBndr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AltCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Stg.Syntax.html#StgApp"><span class="hs-identifier hs-type">StgApp</span></a></span><span> </span><span id="local-6989586621680955361"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955361"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955361"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Id -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621680955366"><span class="hs-identifier hs-var">bndr</span></a></span><span>
</span><span id="line-423"></span><span>    </span><span class="annot"><a href="#local-6989586621680955362"><span class="hs-identifier hs-var">isBndr</span></a></span><span> </span><span class="annot"><span class="annottext">(AltCon, [Id], GenStgExpr 'Vanilla)
</span><span class="hs-identifier">_</span></span><span>                   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-424"></span><span>
</span><span id="line-425"></span><span>
</span><span id="line-426"></span><span class="hs-comment">{- Note [Care with loop breakers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When doing CSE on a letrec we must be careful about loop
breakers.  Consider
  rec { y = K z
      ; z = K z }
Now if, somehow (and wrongly)), y and z are both marked as
loop-breakers, we do *not* want to drop the (z = K z) binding
in favour of a substitution (z :-&gt; y).

I think this bug will only show up if the loop-breaker-ness is done
wrongly (itself a bug), but it still seems better to do the right
thing regardless.
-}</span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span class="hs-comment">-- Utilities</span><span>
</span><span id="line-442"></span><span>
</span><span id="line-443"></span><span class="hs-comment">-- | This function short-cuts let-bindings that are now obsolete</span><span>
</span><span id="line-444"></span><span id="local-6989586621680955754"><span id="local-6989586621680955755"><span class="annot"><a href="GHC.Stg.CSE.html#mkStgLet"><span class="hs-identifier hs-type">mkStgLet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621680955755"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680955754"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680955754"><span class="hs-identifier hs-type">b</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621680955755"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680955754"><span class="hs-identifier hs-type">b</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621680955754"><span class="hs-identifier hs-type">b</span></a></span></span></span><span>
</span><span id="line-445"></span><span id="mkStgLet"><span class="annot"><span class="annottext">mkStgLet :: forall a b. (a -&gt; b -&gt; b) -&gt; Maybe a -&gt; b -&gt; b
</span><a href="GHC.Stg.CSE.html#mkStgLet"><span class="hs-identifier hs-var hs-var">mkStgLet</span></a></span></span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><span class="hs-identifier">_</span></span><span>      </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>      </span><span id="local-6989586621680955360"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680955360"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680955360"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-446"></span><span class="annot"><a href="GHC.Stg.CSE.html#mkStgLet"><span class="hs-identifier hs-var">mkStgLet</span></a></span><span> </span><span id="local-6989586621680955359"><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955359"><span class="hs-identifier hs-var">stgLet</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621680955358"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680955358"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621680955357"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680955357"><span class="hs-identifier hs-var">body</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; b -&gt; b
</span><a href="#local-6989586621680955359"><span class="hs-identifier hs-var">stgLet</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621680955358"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621680955357"><span class="hs-identifier hs-var">body</span></a></span><span>
</span><span id="line-447"></span><span>
</span><span id="line-448"></span><span>
</span><span id="line-449"></span><span class="hs-comment">{-
Note [All alternatives are the binder]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When all alternatives simply refer to the case binder, then we do not have
to bother with the case expression at all (#13588). CoreSTG does this as well,
but sometimes, types get into the way:

    newtype T = MkT Int
    f :: (Int, Int) -&gt; (T, Int)
    f (x, y) = (MkT x, y)

Core cannot just turn this into

    f p = p

as this would not be well-typed. But to STG, where MkT is no longer in the way,
we can.

Note [Trivial case scrutinee]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We want to be able to handle nested reconstruction of constructors as in

    nested :: Either Int (Either Int a) -&gt; Either Bool (Either Bool a)
    nested (Right (Right v)) = Right (Right v)
    nested _ = Left True

So if we come across

    case x of r1
      Right a -&gt; case a of r2
              Right b -&gt; let v = Right b
                         in Right v

we first replace v with r2. Next we want to replace Right r2 with r1. But the
ce_conAppMap contains Right a!

Therefore, we add r1 &#8614; x to ce_bndrMap when analysing the outer case, and use
this substitution before looking Right r2 up in ce_conAppMap, and everything
works out.

Note [Free variables of an StgClosure]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StgClosures (function and thunks) have an explicit list of free variables:

foo [x] =
    let not_a_free_var = Left [x]
    let a_free_var = Right [x]
    let closure = \[x a_free_var] -&gt; \[y] -&gt; bar y (Left [x]) a_free_var
    in closure

If we were to CSE `Left [x]` in the body of `closure` with `not_a_free_var`,
then the list of free variables would be wrong, so for now, we do not CSE
across such a closure, simply because I (Joachim) was not sure about possible
knock-on effects. If deemed safe and worth the slight code complication of
re-calculating this list during or after this pass, this can surely be done.
-}</span><span>
</span><span id="line-506"></span></pre></body></html>